利用curl验证ssl网站(webservice)

curl的用法:

  http://linux.about.com/od/commands/l/blcmdl1_curl.htm

DER格式的cert转换为PEM格式(curl只接受PEM格式):

  openssl x509 -inform der -in cert.cer -out cert.pem

curl命令示意:

  curl --cacert rootca.pem (或--capath 'certpath' -H 'Content-Type: text/xml; charset=utf-8' -H 'SOAPAction: "http://tempuri.org/HeartBeat"' https://xxxx.asmx -data @heartbeat.xml

curl 的--capath参数:

  在capath指明的路径下存放着验证ssl网站的证书链,必须用c_rehash进行处理的。c_rehash就类似如下代码:

  

for file in *.pem; 
do
    ln -s $file `openssl x509 -hash -noout -in $file `.0;
done

heartbeat.xml是参数经过htmlencode的文件:

  BTGS不让拷贝东西,我只有大概描述下了。<soap12:Envelope>和<soap12:body>是固定的,webservice都差不多。

<soap12:body>下面是<HeartBeat xmlns="http://tempuri.org/">, 参数只有一个<who>内容是转义的,比如“<”要替换成“&lt;“等,网上有在线转义工具。

  BTGS受不了了,向分享总结个东西都这么的费劲。

原文地址:https://www.cnblogs.com/Persue-A-Good-Life/p/4135909.html