如何导出certificate?
方法1) 通过浏览器导出证书,这个功能好像firefox比较简单,Chrome和safari找起来比较麻烦。
firefox->url(https://www.google.com)->click "i(nformation)"->more information->view Certificate->Details->Export即可。
方法2) 还可以通过下面命令行的方式来导出证书:
Unix: openssl s_client -connect google.com:443 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt Windows: openssl s_client -connect google.com:443 < NUL | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > public.crt
如果没有安装sed,还可以:
openssl s_client -connect google.com:443 然后保存结果到一个文件中去,可以命名为public.cert 它包含的内容为: -----BEGIN CERTIFICATE----- < Certificate content as fetched by the command line. Don't change this content, only remove what is before and after the BEGIN CERTIFICATE and END CERTIFICATE. That's what your Sed command is doing for you :-) > -----END CERTIFICATE-----
方法3)还可以通过portecle这个工具来导出证书。
Examine->Examine SSL/TLS Connection ->SSL Host & Port -> PEM Encoding -> Export
这工具也能import certificate到你的keystore中去。