简体   繁体   English

运行python的Windows Docker容器中的证书验证错误

[英]Certificate Verification Error in Windows Docker container running python

I'm just starting out using python to make use of third party api's to improve workflows at our company. 我刚开始使用python来利用第三方api来改善我们公司的工作流程。 One API that I've been working with is for citrix sharefile (a secure, managed FTP server). 我一直在使用的一个API是citrix sharefile(一种安全的托管FTP服务器)。 I use the module that citrix had written as an example to make the api calls so there is at least one layer of abstraction between what I'm writing and the actual HTTP requests. 我使用citrix编写的模块作为示例来进行api调用,因此在我编写的内容和实际的HTTP请求之间至少存在一层抽象。

When I make the authentication request to get an access token from my laptop this works fine, however when I try to do the same thing from inside a docker container (windows nano with python installed) I get this back as a response: 当我提出身份验证请求以从笔记本电脑获取访问令牌时,此方法工作正常,但是当我尝试从Docker容器(安装了python的Windows nano)中执行相同操作时,我将其作为响应返回:

    Traceback (most recent call last):
  File "main.py", line 38, in <module>
    sharefile = pysharefile.authenticate(hostname,sf_client_id,sf_client_secret,sf_username,sf_password)
  File "C:\Python\lib\site-packages\pysharefile\pysharefile.py", line 42, in authenticate
    http.request('POST', uri_path, urllib.parse.urlencode(params), headers=headers)
  File "C:\Python\lib\http\client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Python\lib\http\client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Python\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Python\lib\http\client.py", line 1026, in _send_output
    self.send(msg)
  File "C:\Python\lib\http\client.py", line 964, in send
    self.connect()
  File "C:\Python\lib\http\client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "C:\Python\lib\ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "C:\Python\lib\ssl.py", line 808, in __init__
    self.do_handshake()
  File "C:\Python\lib\ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "C:\Python\lib\ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)

From what I've read it could be because the container can't access the certificates on my computer but if so, how would I install an SSL certificate in the container? 从我读到的内容来看,可能是因为容器无法访问我的计算机上的证书,但是如果是这样,我将如何在容器中安装SSL证书?

Thanks, Austin 谢谢,奥斯丁

If the certificate store on the host is compatible with the guest, you can just mount it directly. 如果主机上的证书存储与来宾兼容,则可以直接安装它。

docker run -v /host/path/to/certs:/container/path/to/certs -d IMAGE_ID "update-ca-certificates" docker运行-v / host / path / to / certs:/ container / path / to / certs -d IMAGE_ID“ update-ca-certificates”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM