SSL_get_conn_close_info.pod 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. =pod
  2. =head1 NAME
  3. SSL_get_conn_close_info, SSL_CONN_CLOSE_FLAG_LOCAL,
  4. SSL_CONN_CLOSE_FLAG_TRANSPORT,
  5. OSSL_QUIC_ERR_NO_ERROR,
  6. OSSL_QUIC_ERR_INTERNAL_ERROR,
  7. OSSL_QUIC_ERR_CONNECTION_REFUSED,
  8. OSSL_QUIC_ERR_FLOW_CONTROL_ERROR,
  9. OSSL_QUIC_ERR_STREAM_LIMIT_ERROR,
  10. OSSL_QUIC_ERR_STREAM_STATE_ERROR,
  11. OSSL_QUIC_ERR_FINAL_SIZE_ERROR,
  12. OSSL_QUIC_ERR_FRAME_ENCODING_ERROR,
  13. OSSL_QUIC_ERR_TRANSPORT_PARAMETER_ERROR,
  14. OSSL_QUIC_ERR_CONNECTION_ID_LIMIT_ERROR,
  15. OSSL_QUIC_ERR_PROTOCOL_VIOLATION,
  16. OSSL_QUIC_ERR_INVALID_TOKEN,
  17. OSSL_QUIC_ERR_APPLICATION_ERROR,
  18. OSSL_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED,
  19. OSSL_QUIC_ERR_KEY_UPDATE_ERROR,
  20. OSSL_QUIC_ERR_AEAD_LIMIT_REACHED,
  21. OSSL_QUIC_ERR_NO_VIABLE_PATH,
  22. OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN,
  23. OSSL_QUIC_ERR_CRYPTO_ERR_END,
  24. OSSL_QUIC_ERR_CRYPTO_ERR,
  25. OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT
  26. - get information about why a QUIC connection was closed
  27. =head1 SYNOPSIS
  28. #include <openssl/ssl.h>
  29. #define SSL_CONN_CLOSE_FLAG_LOCAL
  30. #define SSL_CONN_CLOSE_FLAG_TRANSPORT
  31. typedef struct ssl_conn_close_info_st {
  32. uint64_t error_code, frame_type;
  33. char *reason;
  34. size_t reason_len;
  35. uint32_t flags;
  36. } SSL_CONN_CLOSE_INFO;
  37. int SSL_get_conn_close_info(SSL *ssl, SSL_CONN_CLOSE_INFO *info,
  38. size_t info_len);
  39. #define OSSL_QUIC_ERR_NO_ERROR 0x00
  40. #define OSSL_QUIC_ERR_INTERNAL_ERROR 0x01
  41. #define OSSL_QUIC_ERR_CONNECTION_REFUSED 0x02
  42. #define OSSL_QUIC_ERR_FLOW_CONTROL_ERROR 0x03
  43. #define OSSL_QUIC_ERR_STREAM_LIMIT_ERROR 0x04
  44. #define OSSL_QUIC_ERR_STREAM_STATE_ERROR 0x05
  45. #define OSSL_QUIC_ERR_FINAL_SIZE_ERROR 0x06
  46. #define OSSL_QUIC_ERR_FRAME_ENCODING_ERROR 0x07
  47. #define OSSL_QUIC_ERR_TRANSPORT_PARAMETER_ERROR 0x08
  48. #define OSSL_QUIC_ERR_CONNECTION_ID_LIMIT_ERROR 0x09
  49. #define OSSL_QUIC_ERR_PROTOCOL_VIOLATION 0x0A
  50. #define OSSL_QUIC_ERR_INVALID_TOKEN 0x0B
  51. #define OSSL_QUIC_ERR_APPLICATION_ERROR 0x0C
  52. #define OSSL_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED 0x0D
  53. #define OSSL_QUIC_ERR_KEY_UPDATE_ERROR 0x0E
  54. #define OSSL_QUIC_ERR_AEAD_LIMIT_REACHED 0x0F
  55. #define OSSL_QUIC_ERR_NO_VIABLE_PATH 0x10
  56. /* Inclusive range for handshake-specific errors. */
  57. #define OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN 0x0100
  58. #define OSSL_QUIC_ERR_CRYPTO_ERR_END 0x01FF
  59. #define OSSL_QUIC_ERR_CRYPTO_ERR(X)
  60. #define OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT
  61. =head1 DESCRIPTION
  62. The SSL_get_conn_close_info() function provides information about why and how a
  63. QUIC connection was closed.
  64. Connection closure information is written to I<*info>, which must be non-NULL.
  65. I<info_len> must be set to C<sizeof(*info)>.
  66. The following fields are set:
  67. =over 4
  68. =item I<error_code>
  69. This is a 62-bit QUIC error code. It is either a 62-bit application error code
  70. (if B<SSL_CONN_CLOSE_FLAG_TRANSPORT> not set in I<flags>) or a 62-bit standard
  71. QUIC transport error code (if B<SSL_CONN_CLOSE_FLAG_TRANSPORT> is set in
  72. I<flags>).
  73. =item I<frame_type>
  74. If B<SSL_CONN_CLOSE_FLAG_TRANSPORT> is set, this may be set to a QUIC frame type
  75. number which caused the connection to be closed. It may also be set to 0 if no
  76. frame type was specified as causing the connection to be closed. If
  77. B<SSL_CONN_CLOSE_FLAG_TRANSPORT> is not set, this is set to 0.
  78. =item I<reason>
  79. If non-NULL, this is intended to be a UTF-8 textual string briefly describing
  80. the reason for connection closure. The length of the reason string in bytes is
  81. given in I<reason_len>. While, if non-NULL, OpenSSL guarantees that this string
  82. will be zero terminated, consider that this buffer may originate from the
  83. (untrusted) peer and thus may also contain zero bytes elsewhere. Therefore, use
  84. of I<reason_len> is recommended.
  85. While it is intended as per the QUIC protocol that this be a UTF-8 string, there
  86. is no guarantee that this is the case for strings received from the peer.
  87. =item B<SSL_CONN_CLOSE_FLAG_LOCAL>
  88. If I<flags> has B<SSL_CONN_CLOSE_FLAG_LOCAL> set, connection closure was locally
  89. triggered. This could be due to an application request (e.g. if
  90. B<SSL_CONN_CLOSE_FLAG_TRANSPORT> is unset), or (if
  91. I<SSL_CONN_CLOSE_FLAG_TRANSPORT> is set) due to logic internal to the QUIC
  92. implementation (for example, if the peer engages in a protocol violation, or an
  93. idle timeout occurs).
  94. If unset, connection closure was remotely triggered.
  95. =item B<SSL_CONN_CLOSE_FLAG_TRANSPORT>
  96. If I<flags> has B<SSL_CONN_CLOSE_FLAG_TRANSPORT> set, connection closure was
  97. triggered for QUIC protocol reasons. Otherwise, connection closure was triggered
  98. by the local or remote application.
  99. =back
  100. The B<OSSL_QUIC_ERR> macro definitions provide the QUIC transport error codes as
  101. defined by RFC 9000. The OSSL_QUIC_ERR_CRYPTO_ERR() macro can be used to convert
  102. a TLS alert code into a QUIC transport error code by mapping it into the range
  103. reserved for such codes by RFC 9000. This range begins at
  104. B<OSSL_QUIC_ERR_CRYPTO_ERR_BEGIN> and ends at B<OSSL_QUIC_ERR_CRYPTO_ERR_END>
  105. inclusive.
  106. =head1 NON-STANDARD TRANSPORT ERROR CODES
  107. Some conditions which can cause QUIC connection termination are not signalled on
  108. the wire and therefore do not have standard error codes. OpenSSL indicates these
  109. errors via SSL_get_conn_close_info() by setting B<SSL_CONN_CLOSE_FLAG_TRANSPORT>
  110. and using one of the following error values. These codes are specific to
  111. OpenSSL, and cannot be sent over the wire, as they are above 2**62.
  112. =over 4
  113. =item B<OSSL_QUIC_LOCAL_ERR_IDLE_TIMEOUT>
  114. The connection was terminated immediately due to the idle timeout expiring.
  115. =back
  116. =head1 RETURN VALUES
  117. SSL_get_conn_close_info() returns 1 on success and 0 on failure. This function
  118. fails if called on a QUIC connection SSL object which has not yet been
  119. terminated. It also fails if called on a QUIC stream SSL object or a non-QUIC
  120. SSL object.
  121. =head1 SEE ALSO
  122. L<SSL_shutdown_ex(3)>
  123. =head1 HISTORY
  124. This function was added in OpenSSL 3.2.
  125. =head1 COPYRIGHT
  126. Copyright 2002-2024 The OpenSSL Project Authors. All Rights Reserved.
  127. Licensed under the Apache License 2.0 (the "License"). You may not use
  128. this file except in compliance with the License. You can obtain a copy
  129. in the file LICENSE in the source distribution or at
  130. L<https://www.openssl.org/source/license.html>.
  131. =cut