Ver código fonte

[System]: Properly propagate exceptions in 'MonoTlsStream'.

(cherry picked from commit a7ab399d093f4aac3f24b862e6075ab9f4fdb9e1)
Martin Baulig 10 anos atrás
pai
commit
e21ff252af

+ 8 - 2
mcs/class/System/Mono.Net.Security/MonoTlsStream.cs

@@ -109,13 +109,19 @@ namespace Mono.Net.Security
 					ServicePointManager.CheckCertificateRevocationList);
 
 				status = WebExceptionStatus.Success;
+			} catch (Exception ex) {
+				status = WebExceptionStatus.SecureChannelFailure;
+				throw;
 			} finally {
 				if (CertificateValidationFailed)
 					status = WebExceptionStatus.TrustFailure;
 
-				request.ServicePoint.UpdateClientCertificate (sslStream.InternalLocalCertificate);
-				if (status != WebExceptionStatus.Success)
+				if (status == WebExceptionStatus.Success)
+					request.ServicePoint.UpdateClientCertificate (sslStream.InternalLocalCertificate);
+				else {
+					request.ServicePoint.UpdateClientCertificate (null);
 					sslStream = null;
+				}
 			}
 
 			try {

+ 1 - 0
mcs/class/System/System.Net/WebConnection.cs

@@ -419,6 +419,7 @@ namespace System.Net
 					status = tlsStream.ExceptionStatus;
 				else if (!request.Aborted)
 					status = WebExceptionStatus.ConnectFailure;
+				connect_exception = ex;
 				return false;
 			}