@@ -856,7 +856,6 @@ _mongoc_secure_channel_sch_credentials_new(const mongoc_ssl_opt_t *opt, PCCERT_C
856
856
{
857
857
SCH_CREDENTIALS * cred = bson_malloc0 (sizeof (SCH_CREDENTIALS ));
858
858
859
- // version
860
859
cred -> dwVersion = SCH_CREDENTIALS_VERSION ;
861
860
862
861
/* SCHANNEL_CRED:
@@ -892,18 +891,11 @@ _mongoc_secure_channel_sch_credentials_new(const mongoc_ssl_opt_t *opt, PCCERT_C
892
891
cred -> paCred = cert ;
893
892
}
894
893
895
- TLS_PARAMETERS tls_parameters ;
896
894
cred -> cTlsParameters = 1 ;
897
- cred -> pTlsParameters = & tls_parameters ;
898
-
899
- // Blocked suites
900
- CRYPTO_SETTINGS crypto_settings [1 ] = { { 0 } };
901
- cred -> pTlsParameters -> cDisabledCrypto = 0 ;
902
- cred -> pTlsParameters -> pDisabledCrypto = crypto_settings ;
903
-
895
+ cred -> pTlsParameters = bson_malloc0 (sizeof (TLS_PARAMETERS ));
904
896
cred -> pTlsParameters -> grbitDisabledProtocols = (DWORD )~enabled_protocols ;
905
897
906
- return (void * )cred ;
898
+ return (void * )cred ;
907
899
}
908
900
909
901
#endif
@@ -950,24 +942,23 @@ _mongoc_secure_channel_schannel_cred_new(const mongoc_ssl_opt_t *opt, PCCERT_CON
950
942
951
943
cred -> grbitEnabledProtocols = enabled_protocols ;
952
944
953
- return (void * )cred ;
945
+ return (void * )cred ;
954
946
}
955
947
956
948
mongoc_secure_channel_cred *
957
949
mongoc_secure_channel_cred_new (const mongoc_ssl_opt_t * opt )
958
950
{
959
951
BSON_ASSERT_PARAM (opt );
960
952
mongoc_secure_channel_cred * cred = bson_malloc0 (sizeof (mongoc_secure_channel_cred ));
961
-
953
+
962
954
bool is_server = IsWindowsServer ();
963
- DWORD enabled_protocols = SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT ;
955
+ DWORD enabled_protocols = SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT ;
964
956
965
- /* TLS 1.3 is supported starting with Windows 11 and Windows Server 2022.
957
+ /* TLS 1.3 is supported on Windows 11 (or Windows Server 2022) and newer.
966
958
* Schannel will not negotiate TLS 1.3 when SCHANNEL_CRED is used. */
967
959
if ((is_server && _mongoc_verify_windows_version (10 , 0 , 19044 , false)) ||
968
960
(!is_server && _mongoc_verify_windows_version (10 , 0 , 22000 , false))) {
969
961
enabled_protocols |= SP_PROT_TLS1_3_CLIENT ;
970
- printf ("Enabling TLS 1.3 with Secure Channel \n" );
971
962
}
972
963
973
964
if (opt -> ca_file ) {
@@ -984,7 +975,7 @@ mongoc_secure_channel_cred_new(const mongoc_ssl_opt_t *opt)
984
975
985
976
#ifdef MONGOC_HAVE_SCH_CREDENTIALS
986
977
// SCH_CREDENTIALS is supported in Windows 10 1809 / Server 1809 and later
987
- if (_mongoc_verify_windows_version (10 , 0 , 17763 , false)) {
978
+ if (_mongoc_verify_windows_version (10 , 0 , 17763 , false)) {
988
979
cred -> cred = _mongoc_secure_channel_sch_credentials_new (opt , & cred -> cert , enabled_protocols );
989
980
cred -> cred_type = sch_credentials ;
990
981
} else {
@@ -1007,6 +998,12 @@ mongoc_secure_channel_cred_deleter(void *cred_void)
1007
998
return ;
1008
999
}
1009
1000
CertFreeCertificateContext (cred -> cert );
1001
+ #ifdef MONGOC_HAVE_SCH_CREDENTIALS
1002
+ if (cred -> cred_type == sch_credentials ) {
1003
+ SCH_CREDENTIALS * sch_cred = (SCH_CREDENTIALS * )cred -> cred ;
1004
+ bson_free (sch_cred -> pTlsParameters );
1005
+ }
1006
+ #endif
1010
1007
bson_free (cred -> cred );
1011
1008
bson_free (cred );
1012
1009
}
@@ -1084,7 +1081,7 @@ mongoc_stream_tls_secure_channel_new_with_creds(mongoc_stream_t *base_stream,
1084
1081
UNISP_NAME , /* security package */
1085
1082
SECPKG_CRED_OUTBOUND , /* we are preparing outbound connection */
1086
1083
NULL , /* Optional logon */
1087
- cred -> cred , /* TLS "configuration", "auth data" */
1084
+ cred -> cred , /* TLS "configuration", "auth data" */
1088
1085
NULL , /* unused */
1089
1086
NULL , /* unused */
1090
1087
& secure_channel -> cred_handle -> cred_handle , /* credential OUT param */
0 commit comments