Skip to content

Commit e339ea4

Browse files
committed
Better OpenSSL headers include based on headers version.
1 parent c6f02b4 commit e339ea4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@
1515
#include <openssl/bio.h>
1616
#include <openssl/err.h>
1717
#include <openssl/pem.h>
18-
#include <openssl/pemerr.h>
1918
#include <openssl/ssl.h>
2019
#include <openssl/x509.h>
2120
#include <openssl/x509_vfy.h>
2221

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.
22+
// openssl/types.h was added in later version of openssl (starting from 3.0.0) and is therefore not always available.
23+
// This is for example the case on Ubuntu 20.04 or Centos 7.
2524
// We try to include it if available to satisfy clang-tidy.
2625
// Ref: https://github.com/openssl/openssl/commit/50cd4768c6b89c757645f28519236bb989216f8d
27-
#if __has_include(<openssl/types.h>)
26+
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2827
#include <openssl/types.h>
2928
#else
3029
#include <openssl/ossl_typ.h>
3130
#endif
3231

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

3539
/**

0 commit comments

Comments
 (0)