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