updated client certificates to handle non-manual case
authorOliver Neal <ItsVeryWindy@users.noreply.github.com>
Tue, 9 Feb 2016 21:52:37 +0000 (21:52 +0000)
committerOliver Neal <oliver.neal@comparethemarket.com>
Fri, 19 Feb 2016 15:41:52 +0000 (15:41 +0000)
mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest/WebRequestHandler.cs

index 4b6649b430aa793d431dd44377d22c746b2d812f..79b6437565231fe4506a54b230e3746c0f6ae8fe 100644 (file)
@@ -83,7 +83,13 @@ namespace System.Net.Http
                }
 
                public X509CertificateCollection ClientCertificates {
-                       get { return clientCertificates; }
+                       get {
+                               if (this.ClientCertificateOptions != ClientCertificateOption.Manual) {
+                                       throw new InvalidOperationException("The ClientCertificateOptions property must be set to 'Manual' to use this property.");
+                               }
+                               
+                               return clientCertificates;
+                       }
                }
 
                [MonoTODO]
@@ -147,7 +153,10 @@ namespace System.Net.Http
                        wr.ReadWriteTimeout = readWriteTimeout;
                        wr.UnsafeAuthenticatedConnectionSharing = unsafeAuthenticatedConnectionSharing;
                        wr.ServerCertificateValidationCallback = serverCertificateValidationCallback;
-                       wr.ClientCertificates = clientCertificates;
+                       
+                       if (this.ClientCertificateOptions == ClientCertificateOption.Manual) {
+                               wr.ClientCertificates = clientCertificates;
+                       }
 
                        return wr;
                }