25#define LOG_PREFIX "tls"
30#include <freeradius-devel/server/log.h>
32static long ssl_built = OPENSSL_VERSION_NUMBER;
52 unsigned long ssl_linked;
54 ssl_linked = OpenSSL_version_num();
64 if ((ssl_linked & 0xff000000) != (ssl_built & 0xff000000)) {
65 ERROR(
"libssl version mismatch. built: %lx linked: %lx",
66 (
unsigned long) ssl_built,
67 (
unsigned long) ssl_linked);
98 (0xf0000000 & v) >> 28,
99 (0x0ff00000 & v) >> 20,
100 (0x00000ff0 & v) >> 4);
114 static _Thread_local
char buffer[40];
130 unsigned long ssl_linked;
132 ssl_linked = OpenSSL_version_num();
144 static _Thread_local
char buffer[256];
146 unsigned long v = OpenSSL_version_num();
149 OpenSSL_version(OPENSSL_VERSION),
156# ifdef ENABLE_OPENSSL_VERSION_CHECK
164} fr_openssl_defect_t;
168# define VM(_a,_b,_c) (((((_a) << 24) | ((_b) << 16) | ((_c) << 8)) << 4) | 0x0f)
169# define Vm(_a,_b,_c,_d) (((((_a) << 24) | ((_b) << 16) | ((_c) << 8) | ((_d) - 'a' + 1)) << 4) | 0x0f)
172static fr_openssl_defect_t fr_openssl_defects[] =
175 .low = Vm(1,1,0,
'a'),
176 .high = Vm(1,1,0,
'a'),
177 .id =
"CVE-2016-6309",
178 .name =
"OCSP status request extension",
179 .comment =
"For more information see https://www.openssl.org/news/secadv/20160926.txt"
184 .id =
"CVE-2016-6304",
185 .name =
"OCSP status request extension",
186 .comment =
"For more information see https://www.openssl.org/news/secadv/20160922.txt"
196int fr_openssl_version_check(
char const *acknowledged)
200 unsigned long ssl_linked;
206 if (!acknowledged || !*acknowledged) {
207 ERROR(
"Refusing to start until 'allow_vulnerable_openssl' is given a value");
211 if (strcmp(acknowledged,
"yes") == 0)
return 0;
214 ssl_linked = OpenSSL_version_num();
215 for (i = 0; i < (
NUM_ELEMENTS(fr_openssl_defects)); i++) {
216 fr_openssl_defect_t *defect = &fr_openssl_defects[i];
218 if ((ssl_linked >= defect->low) && (ssl_linked <= defect->high)) {
222 if (!bad && (strcmp(acknowledged, defect->id) == 0))
return 0;
224 ERROR(
"Refusing to start with libssl version %s (in range %s)",
226 ERROR(
"Security advisory %s (%s)", defect->id, defect->name);
227 ERROR(
"%s", defect->comment);
233 INFO(
"Once you have verified libssl has been correctly patched, "
234 "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)
char const * fr_openssl_version_basic(void)
int fr_openssl_version_consistent(void)
char const * fr_openssl_version_expanded(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.