|
| 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 | +/** |
| 21 | + * @file custom_x509_extensions.h |
| 22 | + * |
| 23 | + * The following API enables applications to configure custom x509 critical extensions unknown to s2n-tls. |
| 24 | + * s2n-tls will ignore these extensions during certificate validation. Applications MUST validate their |
| 25 | + * custom critical extensions in the cert validation callback or after the handshake. |
| 26 | + */ |
| 27 | + |
| 28 | +/** |
| 29 | + * Specify a custom critical extension to be ignored during certificate validation. |
| 30 | + * |
| 31 | + * By default, s2n-tls will reject received certificates with unknown critical extensions. Calling |
| 32 | + * s2n_config_add_custom_x509_extension will mark the given extension_oid as known and handled. |
| 33 | + * This allows applications to provide their own validation for certificate extensions unknown to s2n-tls. |
| 34 | + * |
| 35 | + * This API adds a single custom critical extension to the config at a time. |
| 36 | + * |
| 37 | + * Libcrypto Requirement: AWS-LC >= 1.51.0 |
| 38 | + * |
| 39 | + * # Safety |
| 40 | + * |
| 41 | + * RFC 5280 indicates that certificate extensions are to be marked critical when validators MUST |
| 42 | + * understand the extension in order to safely determine the certificate's validity. As such, s2n-tls |
| 43 | + * assumes that this validation is performed by the application. Applications MUST implement this |
| 44 | + * validation for all provided certificate extensions outside of s2n-tls. The `s2n_cert_validation_callback` |
| 45 | + * can be used for this purpose. An alternative is to wait until after the handshake completes, |
| 46 | + * but before any application data is sent or accepted. |
| 47 | + * |
| 48 | + * @param config The configuration object being updated |
| 49 | + * @param extension_oid The pointer to a custom critical extension OID |
| 50 | + * @param extension_oid_len The length of the extension OID |
| 51 | + * @returns S2N_SUCCESS on success. S2N_FAILURE on failure |
| 52 | + */ |
| 53 | +S2N_API extern int s2n_config_add_custom_x509_extension(struct s2n_config *config, uint8_t *extension_oid, uint32_t extension_oid_len); |
0 commit comments