SSL_CTX_set1_cert_comp_preference.pod 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set1_cert_comp_preference,
  4. SSL_set1_cert_comp_preference,
  5. SSL_CTX_compress_certs,
  6. SSL_compress_certs,
  7. SSL_CTX_get1_compressed_cert,
  8. SSL_get1_compressed_cert,
  9. SSL_CTX_set1_compressed_cert,
  10. SSL_set1_compressed_cert - Certificate compression functions
  11. =head1 SYNOPSIS
  12. #include <openssl/ssl.h>
  13. int SSL_CTX_set1_cert_comp_preference(SSL_CTX *ctx, int *algs, size_t len);
  14. int SSL_set1_cert_comp_preference(SSL *ssl, int *algs, size_t len);
  15. int SSL_CTX_compress_certs(SSL_CTX *ctx, int alg);
  16. int SSL_compress_certs(SSL *ssl, int alg);
  17. size_t SSL_CTX_get1_compressed_cert(SSL_CTX *ctx, int alg, unsigned char **data,
  18. size_t *orig_len);
  19. size_t SSL_get1_compressed_cert(SSL *ssl, int alg, unsigned char **data,
  20. size_t *orig_len);
  21. int SSL_CTX_set1_compressed_cert(SSL_CTX *ctx, int alg,
  22. unsigned char *comp_data,
  23. size_t comp_length, size_t orig_length);
  24. int SSL_set1_compressed_cert(SSL *ssl, int alg, unsigned char *comp_data,
  25. size_t comp_length, size_t orig_length);
  26. =head1 DESCRIPTION
  27. These functions control the certificate compression feature. Certificate
  28. compression is only available for TLSv1.3 as defined in RFC8879.
  29. SSL_CTX_set1_cert_comp_preference() and SSL_set1_cert_comp_preference() are used
  30. to specify the preferred compression algorithms. The B<algs> argument is an array
  31. of algorithms, and B<length> is number of elements in the B<algs> array. Only
  32. those algorithms enabled in the library will be accepted in B<algs>, unknown
  33. algorithms in B<algs> are ignored. On an error, the preference order is left
  34. unmodified.
  35. The following compression algorithms (B<alg> arguments) may be used:
  36. =over 4
  37. =item * TLSEXT_comp_cert_brotli
  38. =item * TLSEXT_comp_cert_zlib
  39. =item * TLSEXT_comp_cert_zstd
  40. =back
  41. The above is also the default preference order. If a preference order is not
  42. specified, then the default preference order is sent to the peer and the
  43. received peer's preference order will be used when compressing a certificate.
  44. Otherwise, the configured preference order is sent to the peer and is used
  45. to filter the peer's preference order.
  46. SSL_CTX_compress_certs() and SSL_compress_certs() are used to pre-compress all
  47. the configured certificates on an SSL_CTX/SSL object with algorithm B<alg>. If
  48. B<alg> is 0, then the certificates are compressed with the algorithms specified
  49. in the preference list. Calling these functions on a client SSL_CTX/SSL object
  50. will result in an error, as only server certificates may be pre-compressed.
  51. SSL_CTX_get1_compressed_cert() and SSL_get1_compressed_cert() are used to get
  52. the pre-compressed certificate most recently set that may be stored for later
  53. use. Calling these functions on a client SSL_CTX/SSL object will result in an
  54. error, as only server certificates may be pre-compressed. The B<data> and
  55. B<orig_len> arguments are required.
  56. The compressed certificate data may be passed to SSL_CTX_set1_compressed_cert()
  57. or SSL_set1_compressed_cert() to provide a pre-compressed version of the
  58. most recently set certificate. This pre-compressed certificate can only be used
  59. by a server.
  60. =head1 NOTES
  61. Each side of the connection sends their compression algorithm preference list
  62. to their peer indicating compressed certificate support. The received preference
  63. list is filtered by the configured preference list (i.e. the intersection is
  64. saved). As the default list includes all the enabled algorithms, not specifying
  65. a preference will allow any enabled algorithm by the peer. The filtered peer's
  66. preference order is used to determine what algorithm to use when sending a
  67. compressed certificate.
  68. Only server certificates may be pre-compressed. Calling any of these functions
  69. (except SSL_CTX_set1_cert_comp_preference()/SSL_set1_cert_comp_preference())
  70. on a client SSL_CTX/SSL object will return an error. Client certificates are
  71. compressed on-demand as unique context data from the server is compressed along
  72. with the certificate.
  73. For SSL_CTX_set1_cert_comp_preference() and SSL_set1_cert_comp_preference()
  74. the B<len> argument is the size of the B<algs> argument in bytes.
  75. The compressed certificate returned by SSL_CTX_get1_compressed_cert() and
  76. SSL_get1_compressed_cert() is the last certificate set on the SSL_CTX/SSL object.
  77. The certificate is copied by the function and the caller must free B<*data> via
  78. OPENSSL_free().
  79. The compressed certificate data set by SSL_CTX_set1_compressed_cert() and
  80. SSL_set1_compressed_cert() is copied into the SSL_CTX/SSL object.
  81. SSL_CTX_compress_certs() and SSL_compress_certs() return an error under the
  82. following conditions:
  83. =over 4
  84. =item * If no certificates have been configured.
  85. =item * If the specified algorithm B<alg> is not enabled.
  86. =item * If B<alg> is 0 and no compression algorithms are enabled.
  87. =back
  88. Sending compressed certificates may be disabled on a connection via the
  89. SSL_OP_NO_TX_CERTIFICATE_COMPRESSION option. Receiving compressed certificates
  90. may be disabled on a connection via the SSL_OP_NO_RX_CERTIFICATE_COMPRESSION
  91. option.
  92. =head1 RETURN VALUES
  93. SSL_CTX_set1_cert_comp_preference(),
  94. SSL_set1_cert_comp_preference(),
  95. SSL_CTX_compress_certs(),
  96. SSL_compress_certs(),
  97. SSL_CTX_set1_compressed_cert(), and
  98. SSL_set1_compressed_cert()
  99. return 1 for success and 0 on error.
  100. SSL_CTX_get1_compressed_cert() and
  101. SSL_get1_compressed_cert()
  102. return the length of the allocated memory on success and 0 on error.
  103. =head1 SEE ALSO
  104. L<SSL_CTX_set_options(3)>,
  105. L<SSL_CTX_use_certificate(3)>
  106. =head1 HISTORY
  107. These functions were added in OpenSSL 3.2.
  108. =head1 COPYRIGHT
  109. Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
  110. Licensed under the Apache License 2.0 (the "License"). You may not use
  111. this file except in compliance with the License. You can obtain a copy
  112. in the file LICENSE in the source distribution or at
  113. L<https://www.openssl.org/source/license.html>.
  114. =cut