zoukankan      html  css  js  c++  java
  • extract the CA cert for a particular server

    Ignore Peer SSL certificate verification 

    libcurl performs peer SSL certificate verification by default. This is done by using a CA certificate store that the SSL library can use to make sure the peer's server certificate is valid.

    If you communicate with HTTPS, FTPS or other TLS-using servers using certificates that are signed by CAs present in the store, you can be sure that the remote server really is the one it claims to be.

    If the remote server uses a self-signed certificate, if you don't install a CA cert store, if the server uses a certificate signed by a CA that isn't included in the store you use or if the remote host is an impostor impersonating your favorite site, and you want to transfer files from this server, do one of the following:

    1. Tell libcurl to not verify the peer. With libcurl you disable this with curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);

      With the curl command line tool, you disable this with -k/--insecure.

    2. Get a CA certificate that can verify the remote server and use the proper option to point out this CA cert for verification when connecting. For libcurl hackers: curl_easy_setopt(curl, CURLOPT_CAPATH, capath);

      With the curl command line tool: --cacert [file]

    Get cert:

    openssl s_client -connect xxxxx.com:443 |tee logfile

    type "QUIT", followed by the "ENTER" key

    The certificate will have "BEGIN CERTIFICATE" and "END CERTIFICATE" markers.

    • -----BEGIN CERTIFICATE-----

      fiQffffpAsiHZ0qZm+ixhTxgkasCKeff5CavSWAvqD7SnpHQ==f

      -----END CERTIFICATE-----

    If you want to see the data in the certificate, you can do: "openssl x509 -inform PEM -in certfile -text -out certdata" where certfile is the cert you extracted from logfile. Look in certdata.

    If you want to trust the certificate, you can add it to your CA certificate store or use it stand-alone as described. Just remember that the security is no better than the way you obtained the certificate.

  • 相关阅读:
    构建调试Linux内核网络代码的环境MenuOS系统
    关于iOS开发证书的一些总结(很有用)
    iOS原型模式
    iOS不用调用,running time自动执行方法
    关于网络设计服务结构的一些理解
    iOS 6.0之后支持一个页面横屏的方法
    iOS返回一个前面没有0,小数点后保留两位的数字字符串
    CoreData总结
    分享一个复用代码块的博客
    分享一个可以打开沙盒的软件
  • 原文地址:https://www.cnblogs.com/sanquanfeng/p/5836148.html
Copyright © 2011-2022 走看看