SSL_SESSION_get0_hostname.pod 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. =pod
  2. =head1 NAME
  3. SSL_SESSION_get0_hostname,
  4. SSL_SESSION_set1_hostname,
  5. SSL_SESSION_get0_alpn_selected,
  6. SSL_SESSION_set1_alpn_selected
  7. - get and set SNI and ALPN data associated with a session
  8. =head1 SYNOPSIS
  9. #include <openssl/ssl.h>
  10. const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);
  11. int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);
  12. void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,
  13. const unsigned char **alpn,
  14. size_t *len);
  15. int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, const unsigned char *alpn,
  16. size_t len);
  17. =head1 DESCRIPTION
  18. SSL_SESSION_get0_hostname() retrieves the Server Name Indication (SNI) value
  19. that was sent by the client when the session was created if the server
  20. acknowledged the client's SNI extension by including an empty SNI extension
  21. in response. Otherwise NULL is returned.
  22. The value returned is a pointer to memory maintained within B<s> and
  23. should not be free'd.
  24. SSL_SESSION_set1_hostname() sets the SNI value for the hostname to a copy of
  25. the string provided in hostname.
  26. SSL_SESSION_get0_alpn_selected() retrieves the selected ALPN protocol for this
  27. session and its associated length in bytes. The returned value of B<*alpn> is a
  28. pointer to memory maintained within B<s> and should not be free'd.
  29. SSL_SESSION_set1_alpn_selected() sets the ALPN protocol for this session to the
  30. value in B<alpn> which should be of length B<len> bytes. A copy of the input
  31. value is made, and the caller retains ownership of the memory pointed to by
  32. B<alpn>.
  33. =head1 RETURN VALUES
  34. SSL_SESSION_get0_hostname() returns the SNI string if available, or NULL if not.
  35. SSL_SESSION_set1_hostname() returns 1 on success or 0 on error.
  36. SSL_SESSION_set1_alpn_selected() returns 1 on success or 0 on error.
  37. =head1 SEE ALSO
  38. L<ssl(7)>,
  39. L<d2i_SSL_SESSION(3)>,
  40. L<SSL_SESSION_get_time(3)>,
  41. L<SSL_SESSION_free(3)>
  42. =head1 HISTORY
  43. The SSL_SESSION_set1_hostname(), SSL_SESSION_get0_alpn_selected() and
  44. SSL_SESSION_set1_alpn_selected() functions were added in OpenSSL 1.1.1.
  45. =head1 COPYRIGHT
  46. Copyright 2016-2025 The OpenSSL Project Authors. All Rights Reserved.
  47. Licensed under the Apache License 2.0 (the "License"). You may not use
  48. this file except in compliance with the License. You can obtain a copy
  49. in the file LICENSE in the source distribution or at
  50. L<https://www.openssl.org/source/license.html>.
  51. =cut