You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.199
Former-commit-id: f4d318e4b2f128fa9f4d31b37bb3839a3fc0dfb2
This commit is contained in:
parent
536cd135cc
commit
5924117973
@ -235,32 +235,41 @@ namespace Mono.AppleTls
|
||||
*
|
||||
*/
|
||||
|
||||
var trust = GetPeerTrust (!IsServer);
|
||||
X509CertificateCollection certificates;
|
||||
|
||||
if (trust == null || trust.Count == 0) {
|
||||
remoteCertificate = null;
|
||||
if (!IsServer)
|
||||
throw new TlsException (AlertDescription.CertificateUnknown);
|
||||
certificates = null;
|
||||
} else {
|
||||
if (trust.Count > 1)
|
||||
Debug ("WARNING: Got multiple certificates in SecTrust!");
|
||||
|
||||
certificates = new X509CertificateCollection ();
|
||||
for (int i = 0; i < trust.Count; i++)
|
||||
certificates.Add (trust [(IntPtr)i].ToX509Certificate ());
|
||||
|
||||
remoteCertificate = certificates [0];
|
||||
Debug ("Got peer trust: {0}", remoteCertificate);
|
||||
}
|
||||
|
||||
bool ok;
|
||||
SecTrust trust = null;
|
||||
X509CertificateCollection certificates = null;
|
||||
|
||||
try {
|
||||
trust = GetPeerTrust (!IsServer);
|
||||
|
||||
if (trust == null || trust.Count == 0) {
|
||||
remoteCertificate = null;
|
||||
if (!IsServer)
|
||||
throw new TlsException (AlertDescription.CertificateUnknown);
|
||||
certificates = null;
|
||||
} else {
|
||||
if (trust.Count > 1)
|
||||
Debug ("WARNING: Got multiple certificates in SecTrust!");
|
||||
|
||||
certificates = new X509CertificateCollection ();
|
||||
for (int i = 0; i < trust.Count; i++)
|
||||
certificates.Add (trust.GetCertificate (i));
|
||||
|
||||
remoteCertificate = new X509Certificate (certificates [0]);
|
||||
Debug ("Got peer trust: {0}", remoteCertificate);
|
||||
}
|
||||
|
||||
ok = ValidateCertificate (certificates);
|
||||
} catch (Exception ex) {
|
||||
Debug ("Certificate validation failed: {0}", ex);
|
||||
throw new TlsException (AlertDescription.CertificateUnknown, "Certificate validation threw exception.");
|
||||
} finally {
|
||||
if (trust != null)
|
||||
trust.Dispose ();
|
||||
if (certificates != null) {
|
||||
for (int i = 0; i < certificates.Count; i++)
|
||||
certificates [i].Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
@ -665,7 +674,7 @@ namespace Mono.AppleTls
|
||||
if (value == IntPtr.Zero)
|
||||
throw new TlsException (AlertDescription.CertificateUnknown);
|
||||
}
|
||||
return (value == IntPtr.Zero) ? null : new SecTrust (value);
|
||||
return (value == IntPtr.Zero) ? null : new SecTrust (value, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user