我试图访问一个合作伙伴的SOAP API,为了这个目标,我做了一个CSR并收到了一个CRT。 我用我的钥匙和CRT制作了一个PEM文件:
cat mycert.crt mykey.key > mycertandkey.pem
当我尝试用curl来打这个服务时:
curl --verbose --cert mycertandkey.pem https://partner/service?wsdl * Hostname was NOT found in DNS cache * Trying IP.IP.IP.IP... * Connected to PARTNER (IP.IP.IP.IP) port 443 (#0) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS alert, Server hello (2): * SSL certificate problem: unable to get local issuer certificate * Closing connection 0 curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
现在,当我尝试使用-k选项时,一切正常,但我宁愿添加他们当前的SSL证书,以便我可以不使用-k选项进行连接。
我想尝试下面的答案中的第二个选项,但目前还没有pipe理: https : //stackoverflow.com/a/24618403/2730032
我使用openssl从我的合作伙伴服务中检索了不同的证书,例如: https : //stackoverflow.com/a/7886248/2730032
之后,我尝试通过https://superuser.com/a/437377将这些证书添加到我的服务器
但是到目前为止,如果没有-k标志,我还是不能curl。 我错在如何检索所需的证书或如何将其添加到我的系统? 还是我误解了我的一般方法?
编辑1:这是当我尝试通过SSL获得证书时会发生什么
openssl s_client -showcerts -connect PARTNER:443 </dev/null CONNECTED(00000003) depth=0 O = PARTNER_INFO, OU = PARTNER_INFO, CN = PARTNER_INFO verify error:num=20:unable to get local issuer certificate verify return:1 depth=0 O = PARTNER_INFO, OU = PARTNER_INFO, CN = PARTNER_INFO verify error:num=27:certificate not trusted verify return:1 depth=0 O = PARTNER_INFO, OU = PARTNER_INFO, CN = PARTNER_INFO verify error:num=21:unable to verify the first certificate verify return:1 --- Certificate chain 0 s:/O=PARTNER_INFO/OU=PARTNER_INFO/CN=PARTNER_INFO i:/C=PARTNER_INFO/ST=PARTNER_INFO/L=PARTNER_INFO/O=PARTNER_INFO/OU=PARTNER_INFO/CN=PARTNER_INFO CA/emailAddress=PARTNER_INFO -----BEGIN CERTIFICATE----- CERTIFICATE1 -----END CERTIFICATE----- 1 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of use at https://www.verisign.com/rpa (c)10/CN=VeriSign Class 3 Secure Server CA - G3 i:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5 -----BEGIN CERTIFICATE----- CERTIFICATE2 -----END CERTIFICATE----- 2 s:/C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=(c) 2006 VeriSign, Inc. - For authorized use only/CN=VeriSign Class 3 Public Primary Certification Authority - G5 i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority -----BEGIN CERTIFICATE----- CERTIFICATE3 -----END CERTIFICATE----- --- Server certificate subject=/O=PARTNER_INFO/OU=PARTNER_INFO/CN=PARTNER_INFO issuer=/C=PARTNER_INFO/ST=PARTNER_INFO/L=PARTNER_INFO/O=PARTNER_INFO/OU=PARTNER_INFO/CN=PARTNER_INFO CA/emailAddress=PARTNER_INFO --- No client certificate CA names sent --- SSL handshake has read 3872 bytes and written 503 bytes --- MORE INFO...
我也试过openssl s_client -showcerts -key mycertandkey.pem -connect PARTNER:443 </dev/null但它给了我相同的结果(和证书)。
编辑2:正如我迄今为止唯一的答案评论:有问题的合作伙伴添加了一个甘地CA到他们的服务器(至less这是他们告诉我),现在的作品。 所以看起来,因为他们的证书现在由我的默认CA软件包中的一个CA签名,我现在可以在没有-k标志的情况下使curl工作。 不过,如果能知道我能如何纠正这个问题,那就太好了。
--cert选项用于指定您自己的证书(客户端证书)。 但是它无法validation服务器证书。 要指定此证书,请使用--cacert或--capath ,具体取决于您拥有服务器证书/ CA的方式(请参阅curl文档)。 请注意,您通常没有服务器证书的专用密钥,因此只能提供不带密钥的证书。
假设你的系统curl是最新的,并且有你的供应商提供的最新的CA证书,那么你不应该导入任何证书。 导入一个你不属于自己的域的证书应该是最后的手段。 如果这样做,build立一个cron工作,每月向你和合作伙伴发送电子邮件,以提醒你们双方解决这个问题。 在证书过期时,将某人导入证书会在稍后导致问题。 您现在必须pipe理不属于您的证书。 与合作伙伴或供应商一起上报,直到他们修好证书安装。
让他们testing他们的网站:
通过Web UI进行testing
Qualys公司
SSL购物者
从命令提示符处
TestSSL这只需要openssl和bash。 这对于不对整个互联网开放的vips / end-points(例如暂存站点)很有用。
只要git clone https://github.com/drwetter/testssl.sh.git然后使用testssh.shvalidation一个HTTPS服务。
SSL站点正确之后
现在您需要确保您的服务器的操作系统中的CA证书是最新的。 更新这些方法随操作系统的发行而变化,并留待系统pipe理员研究。
导入Certs
一旦您确认您的合作伙伴网站设置正确, 这意味着,它在Qualys,SSL Shopper和TestSSL.sh中正确validation
将证书复制到/etc/pki/ca-trust/source/anchors/ import并validation它。
cp /path/to/bad_partner_cert.pem /etc/pki/ca-trust/source/anchors/ update-ca-trust enable update-ca-trust extract openssl verify /etc/pki/ca-trust/source/anchors/bad_partner_cert.pem
再次,这应该是最后的手段,而且是非常临时的 ,因为你现在正在pipe理一个不属于你的证书。