70
70
#include <mongoc/mongoc-stream-tls-private.h>
71
71
#endif
72
72
73
+ #if defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL )
74
+ #include <mongoc/mongoc-stream-tls-secure-channel-private.h>
75
+ #include <mongoc/mongoc-stream-tls-private.h>
76
+ #endif
77
+
73
78
#include <common-string-private.h>
74
79
#include <mlib/cmp.h>
75
80
@@ -756,6 +761,7 @@ mongoc_client_connect (bool buffered,
756
761
const mongoc_uri_t * uri ,
757
762
const mongoc_host_list_t * host ,
758
763
void * openssl_ctx_void ,
764
+ mongoc_shared_ptr secure_channel_cred_ptr ,
759
765
bson_error_t * error )
760
766
{
761
767
mongoc_stream_t * base_stream = NULL ;
@@ -765,6 +771,7 @@ mongoc_client_connect (bool buffered,
765
771
BSON_ASSERT (host );
766
772
767
773
BSON_UNUSED (openssl_ctx_void );
774
+ BSON_UNUSED (secure_channel_cred_ptr );
768
775
769
776
#ifndef MONGOC_ENABLE_SSL
770
777
if (ssl_opts_void || mongoc_uri_get_tls (uri )) {
@@ -814,6 +821,9 @@ mongoc_client_connect (bool buffered,
814
821
// Use shared OpenSSL context.
815
822
base_stream = mongoc_stream_tls_new_with_hostname_and_openssl_context (
816
823
base_stream , host -> host , ssl_opts , true, (SSL_CTX * ) openssl_ctx_void );
824
+ #elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL )
825
+ // Use shared Secure Channel credentials.
826
+ base_stream = mongoc_stream_tls_new_with_secure_channel_cred (base_stream , ssl_opts , secure_channel_cred_ptr );
817
827
#else
818
828
base_stream = mongoc_stream_tls_new_with_hostname (base_stream , host -> host , ssl_opts , true);
819
829
#endif
@@ -881,9 +891,13 @@ mongoc_client_default_stream_initiator (const mongoc_uri_t *uri,
881
891
882
892
#if defined(MONGOC_ENABLE_SSL_OPENSSL ) && OPENSSL_VERSION_NUMBER >= 0x10100000L
883
893
SSL_CTX * ssl_ctx = client -> topology -> scanner -> openssl_ctx ;
884
- return mongoc_client_connect (true, use_ssl , ssl_opts_void , uri , host , (void * ) ssl_ctx , error );
894
+ return mongoc_client_connect (
895
+ true, use_ssl , ssl_opts_void , uri , host , (void * ) ssl_ctx , MONGOC_SHARED_PTR_NULL , error );
896
+ #elif defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL )
897
+ mongoc_shared_ptr cred_ptr = client -> topology -> scanner -> secure_channel_cred_ptr ;
898
+ return mongoc_client_connect (true, use_ssl , ssl_opts_void , uri , host , NULL , cred_ptr , error );
885
899
#else
886
- return mongoc_client_connect (true, use_ssl , ssl_opts_void , uri , host , NULL , error );
900
+ return mongoc_client_connect (true, use_ssl , ssl_opts_void , uri , host , NULL , MONGOC_SHARED_PTR_NULL , error );
887
901
#endif
888
902
}
889
903
@@ -1028,6 +1042,12 @@ _mongoc_client_set_ssl_opts_for_single_or_pooled (mongoc_client_t *client, const
1028
1042
SSL_CTX_free (client -> topology -> scanner -> openssl_ctx );
1029
1043
client -> topology -> scanner -> openssl_ctx = _mongoc_openssl_ctx_new (& client -> ssl_opts );
1030
1044
#endif
1045
+
1046
+ #if defined(MONGOC_ENABLE_SSL_SECURE_CHANNEL )
1047
+ mongoc_shared_ptr_reset (& client -> topology -> scanner -> secure_channel_cred_ptr ,
1048
+ mongoc_secure_channel_cred_new (& client -> ssl_opts ),
1049
+ mongoc_secure_channel_cred_deleter );
1050
+ #endif
1031
1051
}
1032
1052
}
1033
1053
#endif // MONGOC_ENABLE_SSL
0 commit comments