@@ -507,10 +507,6 @@ wildcard_certificate_match(const char *pattern, const char *string)
507
507
return 1 ;
508
508
}
509
509
510
- #if OPENSSL_VERSION_NUMBER < 0x10100000L
511
- #define ASN1_STRING_get0_data ASN1_STRING_data
512
- #endif
513
-
514
510
/*
515
511
* Check if a name from a server's certificate matches the peer's hostname.
516
512
*
@@ -545,7 +541,11 @@ verify_peer_name_matches_certificate_name(PGconn *conn, ASN1_STRING *name_entry,
545
541
* There is no guarantee the string returned from the certificate is
546
542
* NULL-terminated, so make a copy that is.
547
543
*/
544
+ #ifdef HAVE_ASN1_STRING_GET0_DATA
548
545
namedata = ASN1_STRING_get0_data (name_entry );
546
+ #else
547
+ namedata = ASN1_STRING_data (name_entry );
548
+ #endif
549
549
len = ASN1_STRING_length (name_entry );
550
550
name = malloc (len + 1 );
551
551
if (name == NULL )
@@ -733,10 +733,13 @@ verify_peer_name_matches_certificate(PGconn *conn)
733
733
return found_match && !got_error ;
734
734
}
735
735
736
- #if defined(ENABLE_THREAD_SAFETY ) && OPENSSL_VERSION_NUMBER < 0x10100000L
736
+ #if defined(ENABLE_THREAD_SAFETY ) && defined( HAVE_CRYPTO_LOCK )
737
737
/*
738
- * Callback functions for OpenSSL internal locking. (OpenSSL 1.1.0
739
- * does its own locking, and doesn't need these anymore.)
738
+ * Callback functions for OpenSSL internal locking. (OpenSSL 1.1.0
739
+ * does its own locking, and doesn't need these anymore. The
740
+ * CRYPTO_lock() function was removed in 1.1.0, when the callbacks
741
+ * were made obsolete, so we assume that if CRYPTO_lock() exists,
742
+ * the callbacks are still required.)
740
743
*/
741
744
742
745
static unsigned long
@@ -766,7 +769,7 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
766
769
PGTHREAD_ERROR ("failed to unlock mutex" );
767
770
}
768
771
}
769
- #endif /* ENABLE_THREAD_SAFETY && OPENSSL_VERSION_NUMBER < 0x10100000L */
772
+ #endif /* ENABLE_THREAD_SAFETY && HAVE_CRYPTO_LOCK */
770
773
771
774
/*
772
775
* Initialize SSL system, in particular creating the SSL_context object
@@ -805,7 +808,7 @@ pgtls_init(PGconn *conn)
805
808
if (pthread_mutex_lock (& ssl_config_mutex ))
806
809
return -1 ;
807
810
808
- #if OPENSSL_VERSION_NUMBER < 0x10100000L
811
+ #ifdef HAVE_CRYPTO_LOCK
809
812
if (pq_init_crypto_lib )
810
813
{
811
814
/*
@@ -846,14 +849,14 @@ pgtls_init(PGconn *conn)
846
849
CRYPTO_set_locking_callback (pq_lockingcallback );
847
850
}
848
851
}
849
- #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
852
+ #endif /* HAVE_CRYPTO_LOCK */
850
853
#endif /* ENABLE_THREAD_SAFETY */
851
854
852
855
if (!SSL_context )
853
856
{
854
857
if (pq_init_ssl_lib )
855
858
{
856
- #if OPENSSL_VERSION_NUMBER >= 0x10100000L
859
+ #ifdef HAVE_OPENSSL_INIT_SSL
857
860
OPENSSL_init_ssl (OPENSSL_INIT_LOAD_CONFIG , NULL );
858
861
#else
859
862
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
@@ -916,7 +919,7 @@ pgtls_init(PGconn *conn)
916
919
static void
917
920
destroy_ssl_system (void )
918
921
{
919
- #if defined(ENABLE_THREAD_SAFETY ) && OPENSSL_VERSION_NUMBER < 0x10100000L
922
+ #if defined(ENABLE_THREAD_SAFETY ) && defined( HAVE_CRYPTO_LOCK )
920
923
/* Mutex is created in initialize_ssl_system() */
921
924
if (pthread_mutex_lock (& ssl_config_mutex ))
922
925
return ;
@@ -1631,7 +1634,7 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
1631
1634
* to retry; do we need to adopt their logic for that?
1632
1635
*/
1633
1636
1634
- #if OPENSSL_VERSION_NUMBER < 0x10100000L
1637
+ #ifndef HAVE_BIO_GET_DATA
1635
1638
#define BIO_get_data (bio ) (bio->ptr)
1636
1639
#define BIO_set_data (bio , data ) (bio->ptr = data)
1637
1640
#endif
@@ -1704,7 +1707,7 @@ my_BIO_s_socket(void)
1704
1707
if (!my_bio_methods )
1705
1708
{
1706
1709
BIO_METHOD * biom = (BIO_METHOD * ) BIO_s_socket ();
1707
- #if OPENSSL_VERSION_NUMBER >= 0x10100000L
1710
+ #ifdef HAVE_BIO_METH_NEW
1708
1711
int my_bio_index ;
1709
1712
1710
1713
my_bio_index = BIO_get_new_index ();
0 commit comments