| 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 | |
| 16 | #pragma once |
| 17 | |
| 18 | #include <s2n.h> |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | /** |
| 25 | * @file npn.h |
| 26 | * |
| 27 | * The Next Protocol Negotiation Extension, or NPN, was an RFC proposal to |
| 28 | * negotiate an application protocol. This proposal was never standardized, and |
| 29 | * it was eventually replaced with the ALPN Extension. However, an early draft |
| 30 | * version of the NPN Extension was implemented in Openssl. |
| 31 | * Now, OpenSSL clients and servers may require this extension in order to connect. |
| 32 | * |
| 33 | * s2n-tls supports NPN to make it easier for users whose peers require this |
| 34 | * extension, but s2n-tls does NOT recommend its use. The specific draft version |
| 35 | * supported is https://datatracker.ietf.org/doc/html/draft-agl-tls-nextprotoneg-03, |
| 36 | * which provides interoperability with OpenSSL. |
| 37 | */ |
| 38 | |
| 39 | /** |
| 40 | * Turns on support for the NPN extension. |
| 41 | * |
| 42 | * This will allow an s2n-tls client to send the NPN extension and an s2n-tls |
| 43 | * server to respond to receiving the NPN extension. However, if their peer |
| 44 | * also indicates support for the ALPN extension, s2n-tls will prefer that. |
| 45 | * |
| 46 | * Use s2n_config_append_protocol_preference() to set up a list of supported protocols. |
| 47 | * After the negotiation for the connection has completed, the agreed-upon protocol |
| 48 | * can be retrieved with s2n_get_application_protocol(). |
| 49 | * |
| 50 | * @param config A pointer to the config object |
| 51 | * @param enable Set to true to enable. Set to false to disable. |
| 52 | * @returns S2N_SUCCESS on success, S2N_FAILURE on error. |
| 53 | */ |
| 54 | S2N_API int s2n_config_set_npn(struct s2n_config *config, bool enable); |
| 55 | |
| 56 | #ifdef __cplusplus |
| 57 | } |
| 58 | #endif |