2 * Copyright 2016 Facebook, Inc.
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 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <openssl/ssl.h>
20 #include <openssl/x509.h>
25 // BoringSSL doesn't have notion of versioning although it defines
26 // OPENSSL_VERSION_NUMBER to maintain compatibility. The following variables are
27 // intended to be specific to OpenSSL.
28 #if !defined(OPENSSL_IS_BORINGSSL)
29 #define FOLLY_OPENSSL_IS_101 \
30 (OPENSSL_VERSION_NUMBER >= 0x1000105fL && \
31 OPENSSL_VERSION_NUMBER < 0x1000200fL)
32 #define FOLLY_OPENSSL_IS_102 \
33 (OPENSSL_VERSION_NUMBER >= 0x1000200fL && \
34 OPENSSL_VERSION_NUMBER < 0x10100000L)
35 #define FOLLY_OPENSSL_IS_110 (OPENSSL_VERSION_NUMBER >= 0x10100000L)
36 #endif // !defined(OPENSSL_IS_BORINGSSL)
38 // This class attempts to "unify" the OpenSSL libssl APIs between OpenSSL 1.0.2,
39 // 1.1.0 and BoringSSL. The general idea is to provide wrapper methods for 1.0.2
40 // which already exist in BoringSSL and 1.1.0, but there are few APIs such as
41 // SSL_CTX_set1_sigalgs_list and so on which exist in 1.0.2 but were removed
44 #ifdef OPENSSL_IS_BORINGSSL
46 int SSL_CTX_set1_sigalgs_list(SSL_CTX* ctx, const char* sigalgs_list);
47 int TLS1_get_client_version(SSL* s);
48 int BIO_meth_set_read(BIO_METHOD* biom, int (*read)(BIO*, char*, int));
49 int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int));
51 #elif FOLLY_OPENSSL_IS_102 || FOLLY_OPENSSL_IS_101
53 int SSL_CTX_up_ref(SSL_CTX* session);
54 int SSL_SESSION_up_ref(SSL_SESSION* session);
55 int X509_up_ref(X509* x);
56 int BIO_meth_set_read(BIO_METHOD* biom, int (*read)(BIO*, char*, int));
57 int BIO_meth_set_write(BIO_METHOD* biom, int (*write)(BIO*, const char*, int));
59 #elif FOLLY_OPENSSL_IS_110
62 #warning Compiling with unsupported OpenSSL version