25 #define LOG_PREFIX "tls"
30 #include <freeradius-devel/server/log.h>
32 static long ssl_built = OPENSSL_VERSION_NUMBER;
52 unsigned long ssl_linked;
54 ssl_linked = OpenSSL_version_num();
64 if ((ssl_linked & 0xfff00000) != (ssl_built & 0xfff00000)) {
65 ERROR(
"libssl version mismatch. built: %lx linked: %lx",
66 (
unsigned long) ssl_built,
67 (
unsigned long) ssl_linked);
91 if (((v & 0xf0000000) >> 28) < 3) {
92 p +=
snprintf(p, end - p,
"%u.%u.%u",
93 (0xf0000000 & v) >> 28,
94 (0x0ff00000 & v) >> 20,
95 (0x000ff000 & v) >> 12);
97 if ((0x00000ff0 & v) >> 4) {
98 *p++ = (char) (0x60 + ((0x00000ff0 & v) >> 4));
106 if ((0x0000000f & v) == 0) {
111 }
else if ((0x0000000f & v) <= 14) {
112 snprintf(p, end - p,
"beta %u", 0x0000000f & v);
114 strlcpy(p,
"release", end - p);
132 (0xf0000000 & v) >> 28,
133 (0x0ff00000 & v) >> 20,
134 (0x00000ff0 & v) >> 4);
148 static _Thread_local
char buffer[40];
164 unsigned long ssl_linked;
166 ssl_linked = OpenSSL_version_num();
178 static _Thread_local
char buffer[256];
180 unsigned long v = OpenSSL_version_num();
183 OpenSSL_version(OPENSSL_VERSION),
190 # ifdef ENABLE_OPENSSL_VERSION_CHECK
198 } fr_openssl_defect_t;
202 # define VM(_a,_b,_c) (((((_a) << 24) | ((_b) << 16) | ((_c) << 8)) << 4) | 0x0f)
203 # define Vm(_a,_b,_c,_d) (((((_a) << 24) | ((_b) << 16) | ((_c) << 8) | ((_d) - 'a' + 1)) << 4) | 0x0f)
206 static fr_openssl_defect_t fr_openssl_defects[] =
209 .low = Vm(1,1,0,
'a'),
210 .high = Vm(1,1,0,
'a'),
211 .id =
"CVE-2016-6309",
212 .name =
"OCSP status request extension",
213 .comment =
"For more information see https://www.openssl.org/news/secadv/20160926.txt"
218 .id =
"CVE-2016-6304",
219 .name =
"OCSP status request extension",
220 .comment =
"For more information see https://www.openssl.org/news/secadv/20160922.txt"
230 int fr_openssl_version_check(
char const *acknowledged)
234 unsigned long ssl_linked;
240 if (!acknowledged || !*acknowledged) {
241 ERROR(
"Refusing to start until 'allow_vulnerable_openssl' is given a value");
245 if (strcmp(acknowledged,
"yes") == 0)
return 0;
248 ssl_linked = OpenSSL_version_num();
249 for (i = 0; i < (
NUM_ELEMENTS(fr_openssl_defects)); i++) {
250 fr_openssl_defect_t *defect = &fr_openssl_defects[i];
252 if ((ssl_linked >= defect->low) && (ssl_linked <= defect->high)) {
256 if (!bad && (strcmp(acknowledged, defect->id) == 0))
return 0;
258 ERROR(
"Refusing to start with libssl version %s (in range %s)",
260 ERROR(
"Security advisory %s (%s)", defect->id, defect->name);
261 ERROR(
"%s", defect->comment);
267 INFO(
"Once you have verified libssl has been correctly patched, "
268 "set security.allow_vulnerable_openssl = '%s'", defect->id);
static int const char char buffer[256]
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
size_t strlcpy(char *dst, char const *src, size_t siz)
int fr_openssl_version_consistent(void)
char const * fr_openssl_version_expanded(void)
char const * fr_openssl_version_basic(void)
char const * fr_openssl_version_str_from_num(uint32_t version)
char const * fr_openssl_version_range(uint32_t low, uint32_t high)
Version checking functions.