Skip to content

Commit b07022c

Browse files
committed
Merge pull request #1213 from T-Maxxx/1209-deprecated-openssl-support
Better OpenSSL headers include based on headers version.
1 parent 25fc7a7 commit b07022c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ compile_commands.json
6161

6262
# macOS
6363
.DS_Store
64+
65+
# CLion
66+
.idea/

cpr/ssl_ctx.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,27 @@
1414

1515
#include <openssl/bio.h>
1616
#include <openssl/err.h>
17+
#include <openssl/opensslv.h>
1718
#include <openssl/pem.h>
18-
#include <openssl/pemerr.h>
1919
#include <openssl/ssl.h>
2020
#include <openssl/x509.h>
2121
#include <openssl/x509_vfy.h>
2222

23-
// openssl/types.h was added in later version of openssl and is therefore not always available.
24-
// This is for example the case on Ubuntu 20.04.
23+
// openssl/types.h was added in later version of openssl (starting from 3.0.0) and is therefore not always available.
24+
// This is for example the case on Ubuntu 20.04 or Centos 7.
2525
// We try to include it if available to satisfy clang-tidy.
2626
// Ref: https://github.com/openssl/openssl/commit/50cd4768c6b89c757645f28519236bb989216f8d
27-
#if __has_include(<openssl/types.h>)
27+
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2828
#include <openssl/types.h>
2929
#else
3030
#include <openssl/ossl_typ.h>
3131
#endif
3232

33+
// openssl/pemerr.h was added in 1.1.1a
34+
#if OPENSSL_VERSION_NUMBER >= 0x1010101fL
35+
#include <openssl/pemerr.h>
36+
#endif
37+
3338
namespace cpr {
3439

3540
/**

0 commit comments

Comments
 (0)