Skip to content

file.managed with http client certificate #40537

Closed

Description

@LrsK

I have a webserver that I want to use as a source in file.managed states. The webserver requires a client certificate for authentication.

I have tried the following after inspecting the state-code:

/opt/my_file:
    file.managed:
        - source: https://myserver.com/my_file
        - source_hash: abc123
        - cert: /etc/my_cert

This does not seem to use the certificate. How can I specify which client certificate to use?

Activity

  1. changed the title [-]file.managed with client certificate[/-] [+]file.managed with http client certificate[/+] on Apr 5, 2017
  2. Ch3LL commented on Apr 5, 2017

    @Ch3LL
    Contributor

    @LrsK i'm not quit seeing this functionality. Where are you seeing that argument? can you point me to the code?

  3. added
    needs-more-info
    on Apr 5, 2017
  4. added this to the Blocked milestone on Apr 5, 2017
  5. LrsK commented on Apr 5, 2017

    @LrsK
    Author

    The file.managed state has a source parameter, that can be set to an http-url. When this is used, the query-function in the utils.http package is called. Here is the code for the query-function:

    def query(url,

    In this function, the client certificate can be set in the cert-parameter, or read from the master or minion config.

    My question is: how can I set the cert parameter in the file.managed state, and have it appear in the query-function?

  6. Ch3LL commented on Apr 6, 2017

    @Ch3LL
    Contributor

    Thanks for clarifying that. From what I can see this does not exist and would need to be added. I started up a pdb debugger and saw this is the stack trace from the file.managed file in the state module to the query call in salt/utils/https.py:

      /testing/salt/states/file.py(1836)managed()
    -> **kwargs
      /testing/salt/modules/file.py(3760)get_managed()
    -> sfn = __salt__['cp.cache_file'](source, saltenv)
      /testing/salt/modules/cp.py(405)cache_file()
    -> result = _client().cache_file(path, saltenv)
      /testing/salt/fileclient.py(178)cache_file()
    -> return self.get_url(path, '', True, saltenv, cachedir=cachedir)
      /testing/salt/fileclient.py(625)get_url()
    -> **get_kwargs
    > /testing/salt/utils/http.py(145)query()
    -> if opts is None:
    

    We will need to get this added. Feel free to take a stab at adding this functionality if interested

  7. added
    Core
    Feature
    and removed
    needs-more-info
    on Apr 6, 2017
  8. modified the milestones: Approved, Blocked on Apr 6, 2017
  9. LrsK commented on Apr 6, 2017

    @LrsK
    Author

    Just to add to the discussion: It seems like this functionality would be useful in all places where the http(s) scheme is used in the source. Another example is the pkg.installed state, and I believe there are other places as well. In fact, it would be nice if other options could be set as well, such as headers, or whether to check the server certificate.

    As far as implementing this, I'm not sure what the best way would be. It seems like options that apply to the source-parameter get their own fields, like source_hash. This would become messy after a while, as more options are added. Would it be better if the concept of a "source" was fleshed out more, and could accept it's own options e.g. like this:

    /opt/my_file:
        file.managed:
            - source: https://myserver.com/my_file
                hash: abc123
                cert: /etc/my_cert
                verify_ssl: True
                headers:
                    - X-Forward-This: ok
                    - X-MyHeader: fun_thing
    

    Please correct me if I am wrong in my assessment. as I'm not very familiar with the salt code base.

  10. stale commented on Sep 28, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

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

    CoreFeatureState-Modulestale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions