npn.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #pragma once
  16. #include <s2n.h>
  17. /**
  18. * @file npn.h
  19. *
  20. * The Next Protocol Negotiation Extension, or NPN, was an RFC proposal to
  21. * negotiate an application protocol. This proposal was never standardized, and
  22. * it was eventually replaced with the ALPN Extension. However, an early draft
  23. * version of the NPN Extension was implemented in Openssl.
  24. * Now, OpenSSL clients and servers may require this extension in order to connect.
  25. *
  26. * s2n-tls supports NPN to make it easier for users whose peers require this
  27. * extension, but s2n-tls does NOT recommend its use. The specific draft version
  28. * supported is https://datatracker.ietf.org/doc/html/draft-agl-tls-nextprotoneg-03,
  29. * which provides interoperability with OpenSSL.
  30. */
  31. /**
  32. * Turns on support for the NPN extension.
  33. *
  34. * This will allow an s2n-tls client to send the NPN extension and an s2n-tls
  35. * server to respond to receiving the NPN extension. However, if their peer
  36. * also indicates support for the ALPN extension, s2n-tls will prefer that.
  37. *
  38. * Use s2n_config_append_protocol_preference() to set up a list of supported protocols.
  39. * After the negotiation for the connection has completed, the agreed-upon protocol
  40. * can be retrieved with s2n_get_application_protocol().
  41. *
  42. * @param config A pointer to the config object
  43. * @param enable Set to true to enable. Set to false to disable.
  44. * @returns S2N_SUCCESS on success, S2N_FAILURE on error.
  45. */
  46. S2N_API int s2n_config_set_npn(struct s2n_config *config, bool enable);