问题描述
后台:
我正在尝试与外部供应商建立SSL上下文连接以进行握手,然后使用xml进行通信连接。
I am trying to create an SSL context connection with an external vendor for handshake and then communicate using an xml over that connection.
clientCert = path["cert_path"]
clientKey = path["key_path"]
PROTOCOL = ssl.PROTOCOL_TLSv1
context = ssl.SSLContext(PROTOCOL)
context.load_default_certs()
context.load_cert_chain(clientCert, clientKey)
conn = httplib.HTTPSConnection(uri, 443, context=context)
conn.request("POST", '/', headers=headers, body=signedRequest) # code breaks here
response = conn.getresponse()
但是此代码断言:
SSLError(1, u'[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:590)
现在,我知道CA证书已正确放置在服务器上,某个地方的路径已经搞砸了。
Now, I know that the CA certificates are correctly placed on server, somewhere the path is getting messed up.
问题
我怎样才能看到这个 ssl
和 openssl 从中挑选CA Certs。
Openssl似乎正在建立正确的连接,所以我需要在这里明确提供ssl的路径。
How can i see what is the CA Path from which this
ssl
and openssl
pick the CA Certs from.
Openssl seems to be making correct connection, so i need to provide the path to ssl explicitly here.
requests.utils
路径可以如下找到,寻找类似于 context.load_default_certs()
的理解
requests.utils
path can be found up as below, looking for something similar to understand for context.load_default_certs()
In [1]: from requests.utils import DEFAULT_CA_BUNDLE_PATH
In [2]: print(DEFAULT_CA_BUNDLE_PATH)
/usr/local/python/path/site-packages/certifi/cacert.pem
推荐答案
确定...找到它:
命令将是
openssl version -a
[someone@somewhere ~]$ openssl version -a
OpenSSL 1.0.1e-fips 11 Feb 2013
built on: Thu Jul 23 19:06:35 UTC 2015
platform: linux-x86_64
options: bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -DTERMIO -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wa,--noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM
OPENSSLDIR: "/etc/pki/tls"
engines: rdrand dynamic
输出中会有一个值
OPENSSLDIR
,这将是基本路径
There would be a value
OPENSSLDIR
in output, this would be the base path
OPENSSLDIR: "/etc/pki/tls"
大多数情况下,这将是一个符号链接,使用
ls -la
到此 OPENSSLDIR
路径
Most of the cases, this would be a symlink, use
ls -la
to this OPENSSLDIR
path
[someone@somewhere ~]$ ls -la /etc/pki/tls
total 32
drwxr-xr-x. 5 root root 4096 Apr 6 10:09 .
drwxr-xr-x. 11 root root 4096 Apr 4 08:47 ..
lrwxrwxrwx 1 root root 19 Apr 6 10:09 cert.pem -> certs/ca-bundle.crt
drwxr-xr-x. 4 root root 4096 Mar 22 18:15 certs
进一步
ls -la
[someone@somewhere ~]$ ls -la /etc/pki/tls/certs/
total 1908
drwxr-xr-x. 4 root root 4096 Mar 22 18:15 .
drwxr-xr-x. 5 root root 4096 Apr 6 10:09 ..
lrwxrwxrwx 1 root root 49 Apr 6 09:54 ca-bundle.crt -> /etc/pki/ca-trust/some/path/of/cert/tls-ca-bundle.pem
并获得实际路径:
/etc/pki/ca-trust/some/path/of/cert/tls-ca-bundle.pem
这篇关于什么是我的openssl和ssl默认CA Certs路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!