简体   繁体   English

PHP curl-发送证书的正确方法?

[英]PHP curl - correct way to send certificate?

Im using a webservice that requires autentication it one cliente certificate sended by curl. 我正在使用一个要求对其进行认证的Web服务,它通过curl发送了一个客户端证书。 I already have the certificate (.pem), the public key and the private key (.pem) extracted from a .pfx file. 我已经从.pfx文件中提取了证书(.pem),公钥和私钥(.pem)。

Im sending then like this: 我发送然后这样:

    curl_setopt($ch, CURLOPT_SSLCERT, '_cert.pem');
    curl_setopt($ch, CURLOPT_SSLKEY, '_priKEY.pem');
    curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
    curl_setopt($ch, CURLOPT_KEYPASSWD, '****');

But the WS always return the message that i need to send the cliente certificate. 但是WS总是返回我需要发送客户端证书的消息。 Whats is the correct way to send? 什么是正确的发送方式?

Other questions: Did i not need to send the public key file? 其他问题:我不需要发送公钥文件吗? and "keypasswd" is realy necessary? 和“ keypasswd”真的必要吗?

I was using " HTTP ", and to send the certificate on the request, i need to use " HTTPS ". 我使用的是“ HTTP ”,并且要根据请求发送证书,我需要使用“ HTTPS ”。

Don't need to use " CURLOPT_SSLCERTTYPE " option when the format is .pem , because the .pem is already the default format. 格式为.pem时 ,无需使用“ CURLOPT_SSLCERTTYPE ”选项,因为.pem已经是默认格式。 The " public key ", usualy, do not need to be sent, only the private key (when the certificate has one). 通常,不需要发送“ 公钥 ”,只需发送私钥(当证书具有一个时)。

The " CURLOPT_KEYPASSWD " need to be used when the private key have some passphrase , other wise, don't use it. 当私钥有一些密码短语时 ,需要使用“ CURLOPT_KEYPASSWD ”,否则,请勿使用它。

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

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