CURLOPT_PROXY_PINNEDPUBLICKEY.3 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.haxx.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .\"
  23. .TH CURLOPT_PROXY_PINNEDPUBLICKEY 3 "May 31, 2017" "libcurl 7.61.1" "curl_easy_setopt options"
  24. .SH NAME
  25. CURLOPT_PROXY_PINNEDPUBLICKEY \- set pinned public key for https proxy
  26. .SH SYNOPSIS
  27. #include <curl/curl.h>
  28. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROXY_PINNEDPUBLICKEY, char *pinnedpubkey);
  29. .SH DESCRIPTION
  30. Pass a pointer to a zero terminated string as parameter. The string can be the
  31. file name of your pinned public key. The file format expected is "PEM" or "DER".
  32. The string can also be any number of base64 encoded sha256 hashes preceded by
  33. "sha256//" and separated by ";"
  34. When negotiating a TLS or SSL connection, the https proxy sends a certificate
  35. indicating its identity. A public key is extracted from this certificate and
  36. if it does not exactly match the public key provided to this option, curl will
  37. abort the connection before sending or receiving any data.
  38. On mismatch, \fICURLE_SSL_PINNEDPUBKEYNOTMATCH\fP is returned.
  39. The application does not have to keep the string around after setting this
  40. option.
  41. .SH DEFAULT
  42. NULL
  43. .SH PROTOCOLS
  44. All TLS based protocols: HTTPS, FTPS, IMAPS, POP3S, SMTPS etc.
  45. .SH EXAMPLE
  46. .nf
  47. CURL *curl = curl_easy_init();
  48. if(curl) {
  49. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  50. curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443");
  51. curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY,
  52. "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjAa3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74Gxa2eg7fRbEgoChTociMee9wno=");
  53. /* Perform the request */
  54. curl_easy_perform(curl);
  55. }
  56. .fi
  57. .SH PUBLIC KEY EXTRACTION
  58. If you do not have the https proxy server's public key file you can extract it
  59. from the https proxy server's certificate.
  60. .nf
  61. # retrieve the server's certificate if you don't already have it
  62. #
  63. # be sure to examine the certificate to see if it is what you expected
  64. #
  65. # Windows-specific:
  66. # - Use NUL instead of /dev/null.
  67. # - OpenSSL may wait for input instead of disconnecting. Hit enter.
  68. # - If you don't have sed, then just copy the certificate into a file:
  69. # Lines from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----.
  70. #
  71. openssl s_client -servername www.example.com -connect www.example.com:443 < /dev/null | sed -n "/-----BEGIN/,/-----END/p" > www.example.com.pem
  72. # extract public key in pem format from certificate
  73. openssl x509 -in www.example.com.pem -pubkey -noout > www.example.com.pubkey.pem
  74. # convert public key from pem to der
  75. openssl asn1parse -noout -inform pem -in www.example.com.pubkey.pem -out www.example.com.pubkey.der
  76. # sha256 hash and base64 encode der to string for use
  77. openssl dgst -sha256 -binary www.example.com.pubkey.der | openssl base64
  78. .fi
  79. The public key in PEM format contains a header, base64 data and a
  80. footer:
  81. .nf
  82. -----BEGIN PUBLIC KEY-----
  83. [BASE 64 DATA]
  84. -----END PUBLIC KEY-----
  85. .fi
  86. .SH AVAILABILITY
  87. PEM/DER support:
  88. 7.52.0: GSKit, GnuTLS, NSS, OpenSSL, PolarSSL, mbedtls, wolfSSL/CyaSSL
  89. sha256 support:
  90. 7.52.0: GnuTLS, NSS, OpenSSL, PolarSSL, mbedtls, wolfSSL/CyaSSL
  91. Other SSL backends not supported.
  92. .SH RETURN VALUE
  93. Returns CURLE_OK if TLS enabled, CURLE_UNKNOWN_OPTION if not, or
  94. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  95. .SH "SEE ALSO"
  96. .BR CURLOPT_PROXY_SSL_VERIFYPEER "(3), "
  97. .BR CURLOPT_PROXY_SSL_VERIFYHOST "(3), "
  98. .BR CURLOPT_PROXY_CAINFO "(3), "
  99. .BR CURLOPT_PROXY_CAPATH "(3), "