Skip to content

Commit f6d9563

Browse files
committed
Add OpenSSL version number to output
1 parent f080022 commit f6d9563

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/native/libs/System.Security.Cryptography.Native/opensslshim.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ static void OpenLibraryOnce(void)
158158

159159
static pthread_once_t g_openLibrary = PTHREAD_ONCE_INIT;
160160

161+
typedef unsigned long(*OpenSSL_version_num_ptr_private)(void);
162+
161163
int OpenLibrary(void)
162164
{
163165
pthread_once(&g_openLibrary, OpenLibraryOnce);
@@ -184,6 +186,25 @@ void InitializeOpenSSLShim(void)
184186
// libcrypto.so.1.1.0/libssl.so.1.1.0
185187
const void* v1_0_sentinel = dlsym(libssl, "SSL_state");
186188

189+
if (v1_0_sentinel)
190+
{
191+
printf("OpenSSL version: 1.0.x\n");
192+
}
193+
else
194+
{
195+
const OpenSSL_version_num_ptr_private opensslnum = (OpenSSL_version_num_ptr_private)dlsym(libssl, "OpenSSL_version_num");
196+
197+
if (opensslnum)
198+
{
199+
unsigned long ver = opensslnum();
200+
printf("OpenSSL version: 0x%lx\n", ver);
201+
}
202+
else
203+
{
204+
printf("OpenSSL version could not be determiend.\n");
205+
}
206+
}
207+
187208
// Only permit a single assignment here so that two assemblies both triggering the initializer doesn't cause a
188209
// race where the fn_ptr is nullptr, then properly bound, then goes back to nullptr right before being used (then bound again).
189210
void* volatile tmp_ptr;
@@ -234,7 +255,7 @@ void InitializeOpenSSLShim(void)
234255

235256
#if defined(TARGET_ARM) && defined(TARGET_LINUX)
236257
c_static_assert_msg(sizeof(time_t) == 8, "Build requires 64-bit time_t.");
237-
258+
238259
// This value will represent a time in year 2038 if 64-bit time is used,
239260
// or 1901 if the lower 32 bits are interpreted as a 32-bit time_t value.
240261
time_t timeVal = (time_t)0x80000000U;

0 commit comments

Comments
 (0)