@@ -69,9 +69,6 @@ internal override bool ValidateCertificate (
69
69
errors |= MonoSslPolicyErrors . RemoteCertificateNotAvailable ;
70
70
return false ;
71
71
}
72
-
73
- if ( wantsChain )
74
- chain = MNS . SystemCertificateValidator . CreateX509Chain ( certificates ) ;
75
72
}
76
73
else
77
74
{
@@ -92,8 +89,7 @@ internal override bool ValidateCertificate (
92
89
// convert cert to native or extract from unityTlsChainImpl.
93
90
var result = UnityTls . unitytls_x509verify_result . UNITYTLS_X509VERIFY_NOT_DONE ;
94
91
UnityTls . unitytls_x509list * certificatesNative = null ;
95
- UnityTls . unitytls_x509list * finalCertificateChainNative =
96
- chain == null ? null : UnityTls . NativeInterface . unitytls_x509list_create ( & errorState ) ;
92
+ UnityTls . unitytls_x509list * finalCertificateChainNative = UnityTls . NativeInterface . unitytls_x509list_create ( & errorState ) ;
97
93
try
98
94
{
99
95
// Things the validator provides that we might want to make use of here:
@@ -145,21 +141,20 @@ internal override bool ValidateCertificate (
145
141
UnityTls . NativeInterface . unitytls_x509list_free ( certificatesNative ) ;
146
142
}
147
143
148
- if ( finalCertificateChainNative != null ) {
149
- chain ? . Dispose ( ) ;
150
- chain = new X509Chain ( new X509ChainImplUnityTls (
151
- UnityTls . NativeInterface . unitytls_x509list_get_ref ( finalCertificateChainNative , & errorState ) ,
152
- reverseOrder : true // the verify callback starts with the root and ends with the leaf. That's the opposite of chain ordering.
153
- ) ) ;
154
- }
144
+ chain ? . Dispose ( ) ;
145
+ var chainImpl = new X509ChainImplUnityTls (
146
+ UnityTls . NativeInterface . unitytls_x509list_get_ref ( finalCertificateChainNative , & errorState ) ,
147
+ reverseOrder : true // the verify callback starts with the root and ends with the leaf. That's the opposite of chain ordering.
148
+ ) ;
149
+ chain = new X509Chain ( chainImpl ) ;
155
150
156
151
errors = UnityTlsConversions . VerifyResultToPolicyErrror ( result ) ;
157
152
// There should be a status per certificate, but once again we're following closely the BTLS implementation
158
153
// https://github.com/mono/mono/blob/1553889bc54f87060158febca7e6b8b9910975f8/mcs/class/System/Mono.Btls/MonoBtlsProvider.cs#L180
159
154
// which also provides only a single status for the entire chain.
160
155
// It is notoriously tricky to implement in OpenSSL to get a status for all invididual certificates without finishing the handshake in the process.
161
156
// This is partially the reason why unitytls_x509verify_X doesn't expose it (TODO!) and likely the reason Mono's BTLS impl ignores this.
162
- unityTlsChainImpl ? . AddStatus ( UnityTlsConversions . VerifyResultToChainStatus ( result ) ) ;
157
+ chainImpl . AddStatus ( UnityTlsConversions . VerifyResultToChainStatus ( result ) ) ;
163
158
return result == UnityTls . unitytls_x509verify_result . UNITYTLS_X509VERIFY_SUCCESS &&
164
159
errorState . code == UnityTls . unitytls_error_code . UNITYTLS_SUCCESS ;
165
160
}
0 commit comments