@@ -1127,19 +1127,19 @@ internal async Task NegotiateEncryption(SslMode sslMode, NpgsqlTimeout timeout,
11271127 var checkCertificateRevocation = Settings . CheckCertificateRevocation ;
11281128
11291129 RemoteCertificateValidationCallback ? certificateValidationCallback ;
1130- X509Certificate2 ? caCert ;
1130+ X509Certificate2Collection ? caCerts ;
11311131 string ? certRootPath = null ;
11321132
11331133 if ( sslMode is SslMode . Prefer or SslMode . Require )
11341134 {
11351135 certificateValidationCallback = SslTrustServerValidation ;
11361136 checkCertificateRevocation = false ;
11371137 }
1138- else if ( ( caCert = DataSource . TransportSecurityHandler . RootCertificateCallback ? . Invoke ( ) ) is not null ||
1138+ else if ( ( ( caCerts = DataSource . TransportSecurityHandler . RootCertificatesCallback ? . Invoke ( ) ) is not null && caCerts . Count > 0 ) ||
11391139 ( certRootPath = Settings . RootCertificate ??
11401140 PostgresEnvironment . SslCertRoot ?? PostgresEnvironment . SslCertRootDefault ) is not null )
11411141 {
1142- certificateValidationCallback = SslRootValidation ( sslMode == SslMode . VerifyFull , certRootPath , caCert ) ;
1142+ certificateValidationCallback = SslRootValidation ( sslMode == SslMode . VerifyFull , certRootPath , caCerts ) ;
11431143 }
11441144 else if ( sslMode == SslMode . VerifyCA )
11451145 {
@@ -1195,7 +1195,7 @@ internal async Task NegotiateEncryption(SslMode sslMode, NpgsqlTimeout timeout,
11951195 if ( Settings . RootCertificate is not null )
11961196 throw new ArgumentException ( NpgsqlStrings . CannotUseSslRootCertificateWithCustomValidationCallback ) ;
11971197
1198- if ( DataSource . TransportSecurityHandler . RootCertificateCallback is not null )
1198+ if ( DataSource . TransportSecurityHandler . RootCertificatesCallback is not null )
11991199 throw new ArgumentException ( NpgsqlStrings . CannotUseValidationRootCertificateCallbackWithCustomValidationCallback ) ;
12001200 }
12011201 }
@@ -1984,7 +1984,7 @@ internal void ClearTransaction(Exception? disposeReason = null)
19841984 ( sender , certificate , chain , sslPolicyErrors )
19851985 => true ;
19861986
1987- static RemoteCertificateValidationCallback SslRootValidation ( bool verifyFull , string ? certRootPath , X509Certificate2 ? caCertificate )
1987+ static RemoteCertificateValidationCallback SslRootValidation ( bool verifyFull , string ? certRootPath , X509Certificate2Collection ? caCertificates )
19881988 => ( _ , certificate , chain , sslPolicyErrors ) =>
19891989 {
19901990 if ( certificate is null || chain is null )
@@ -2001,12 +2001,12 @@ static RemoteCertificateValidationCallback SslRootValidation(bool verifyFull, st
20012001
20022002 if ( certRootPath is null )
20032003 {
2004- Debug . Assert ( caCertificate is not null ) ;
2005- certs . Add ( caCertificate ) ;
2004+ Debug . Assert ( caCertificates is { Count : > 0 } ) ;
2005+ certs . AddRange ( caCertificates ) ;
20062006 }
20072007 else
20082008 {
2009- Debug . Assert ( caCertificate is null ) ;
2009+ Debug . Assert ( caCertificates is null or { Count : > 0 } ) ;
20102010 if ( Path . GetExtension ( certRootPath ) . ToUpperInvariant ( ) != ".PFX" )
20112011 certs . ImportFromPemFile ( certRootPath ) ;
20122012
0 commit comments