Skip to content

Improve handling of key environment variables (as they do not work on Windows systems) #251

Open

Description

@jmckenna
  • this is a long reported issue (many tickets in MapServer codebase over a decade or more) where environment variables do not work on all Windows systems (no matter what the web server is)
  • an example key environment variable, that is relied upon by the MapCache codebase is CURL_CA_BUNDLE
  • MapCache in /mapcache/lib/http.c faces this same problem on Windows systems (MS4W has had to do various workarounds because of this, for years, for both MapCache and MapServer)
  • pull request WIP: Use CPLSetConfigOption/CPLGetConfigOption for some CGI/FastCGI-related env vars. MapServer#6304 enables use of that variable through the mapfile CONFIG parameter
  • update: I wonder if we could have a new section in mapcache.xml named <environment_variables>, and these would take precedence (use this value, otherwise use the one found at the system level).

Thoughts?

Activity

  1. geographika commented on Aug 10, 2021

    @geographika
    Member

    @jmckenna - where wre you able to pass the file path in CURL_CA_BUNDLE to cURL?
    In MapServer we have the following line at https://github.com/MapServer/MapServer/blob/c862b04cf690091995df40139a6be77a2ff72bce/maphttp.c#L579

          unchecked_curl_easy_setopt(http_handle, CURLOPT_CAINFO, pszCurlCABundle );
    

    The XML approach sounds good. Alternatively the CPLGetConfigOption approach used in MapServer could be used.

  2. dafvid commented on Nov 22, 2024

    @dafvid

    Old but still open issue. I can confirm this works fine. For the first request! Are there something somewhere inside mapcache that clears the environment between requests? It seems like it.

    System
    Windows server 2022
    IIS 10 + mapcache fast cgi

    Steps to reproduce:

    1. Set CURL_CA_BUNDLE
    2. Make first request
    3. Witness one single tile being fetched from a HTTPS-only WMS
    4. Make a second request
    5. Recieve a SSL certificate problem: unable to get local issuer certificate
    6. Restart/kill the fastcgi server
    7. Goto 2

    If i set the fast cgi to reload after just one request everything works but obviously VERY slow. So my best guess is that the environment get reset between request and the part that sets environment variables only does so on startup.

    I can create a new issue from this if that is more apropriate but it's related to this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions