Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/DevicePortal.cs +3 −5 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// Issuer for the device certificate. /// </summary> public static readonly string DevicePortalCertificateIssuer = "CN=Microsoft Windows Web Management"; public static readonly string DevicePortalCertificateIssuer = "Microsoft Windows Web Management"; /// <summary> /// Endpoint used to access the certificate. Loading Loading @@ -149,11 +149,9 @@ namespace Microsoft.Tools.WindowsDevicePortal DeviceConnectionStatus.Connecting, DeviceConnectionPhase.AcquiringCertificate, connectionPhaseDescription); #if WINDOWS_UWP this.SetDeviceCertificate(await this.GetDeviceCertificate()); #else this.deviceConnection.SetDeviceCertificate(await this.GetDeviceCertificate()); #endif certificateAcquired = true; } catch Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/CertificateHandling.cs +7 −24 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ using Windows.Foundation; using Windows.Security.Cryptography.Certificates; using Windows.Storage.Streams; using Windows.Web.Http; using Windows.Web.Http.Filters; namespace Microsoft.Tools.WindowsDevicePortal { Loading Loading @@ -46,7 +47,11 @@ namespace Microsoft.Tools.WindowsDevicePortal try { using (HttpClient client = new HttpClient()) HttpBaseProtocolFilter requestSettings = new HttpBaseProtocolFilter(); requestSettings.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted); requestSettings.AllowUI = false; using (HttpClient client = new HttpClient(requestSettings)) { IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> responseOperation = client.GetAsync(uri); TaskAwaiter<HttpResponseMessage> responseAwaiter = responseOperation.GetAwaiter(); Loading @@ -65,7 +70,7 @@ namespace Microsoft.Tools.WindowsDevicePortal } certificate = new Certificate(bufferOperation.GetResults()); if (!certificate.Issuer.StartsWith(DevicePortalCertificateIssuer)) if (!certificate.Issuer.Contains(DevicePortalCertificateIssuer)) { certificate = null; throw new DevicePortalException( Loading Loading @@ -94,27 +99,5 @@ namespace Microsoft.Tools.WindowsDevicePortal } } #pragma warning restore 1998 /// <summary> /// Sets the device's root certificate in the certificate store. /// </summary> /// <param name="certificate">The device's root certificate.</param> private void SetDeviceCertificate(Certificate certificate) { // Verify that the certificate is one we recognize. if (!certificate.Issuer.StartsWith(DevicePortalCertificateIssuer)) { certificate = null; throw new DevicePortalException( (HttpStatusCode)0, "Invalid certificate issuer", null, "Failed to set the device certificate"); } // Install the certificate. CertificateStore trustedStore = CertificateStores.TrustedRootCertificationAuthorities; trustedStore.Add(certificate); } } } WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestGet.cs +2 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ using System; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; using Windows.Foundation; using Windows.Security.Credentials; Loading Loading @@ -68,7 +69,7 @@ namespace Microsoft.Tools.WindowsDevicePortal } } return null; return (dataBuffer != null) ? dataBuffer.AsStream() : null; } #pragma warning restore 1998 } Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/CertificateHandling.cs +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ namespace Microsoft.Tools.WindowsDevicePortal // Validate the issuer. certificate = new X509Certificate2(certData); if (!certificate.IssuerName.Name.StartsWith(DevicePortalCertificateIssuer)) if (!certificate.IssuerName.Name.Contains(DevicePortalCertificateIssuer)) { certificate = null; throw new DevicePortalException( Loading Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/DevicePortal.cs +3 −5 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// Issuer for the device certificate. /// </summary> public static readonly string DevicePortalCertificateIssuer = "CN=Microsoft Windows Web Management"; public static readonly string DevicePortalCertificateIssuer = "Microsoft Windows Web Management"; /// <summary> /// Endpoint used to access the certificate. Loading Loading @@ -149,11 +149,9 @@ namespace Microsoft.Tools.WindowsDevicePortal DeviceConnectionStatus.Connecting, DeviceConnectionPhase.AcquiringCertificate, connectionPhaseDescription); #if WINDOWS_UWP this.SetDeviceCertificate(await this.GetDeviceCertificate()); #else this.deviceConnection.SetDeviceCertificate(await this.GetDeviceCertificate()); #endif certificateAcquired = true; } catch Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/CertificateHandling.cs +7 −24 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ using Windows.Foundation; using Windows.Security.Cryptography.Certificates; using Windows.Storage.Streams; using Windows.Web.Http; using Windows.Web.Http.Filters; namespace Microsoft.Tools.WindowsDevicePortal { Loading Loading @@ -46,7 +47,11 @@ namespace Microsoft.Tools.WindowsDevicePortal try { using (HttpClient client = new HttpClient()) HttpBaseProtocolFilter requestSettings = new HttpBaseProtocolFilter(); requestSettings.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted); requestSettings.AllowUI = false; using (HttpClient client = new HttpClient(requestSettings)) { IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> responseOperation = client.GetAsync(uri); TaskAwaiter<HttpResponseMessage> responseAwaiter = responseOperation.GetAwaiter(); Loading @@ -65,7 +70,7 @@ namespace Microsoft.Tools.WindowsDevicePortal } certificate = new Certificate(bufferOperation.GetResults()); if (!certificate.Issuer.StartsWith(DevicePortalCertificateIssuer)) if (!certificate.Issuer.Contains(DevicePortalCertificateIssuer)) { certificate = null; throw new DevicePortalException( Loading Loading @@ -94,27 +99,5 @@ namespace Microsoft.Tools.WindowsDevicePortal } } #pragma warning restore 1998 /// <summary> /// Sets the device's root certificate in the certificate store. /// </summary> /// <param name="certificate">The device's root certificate.</param> private void SetDeviceCertificate(Certificate certificate) { // Verify that the certificate is one we recognize. if (!certificate.Issuer.StartsWith(DevicePortalCertificateIssuer)) { certificate = null; throw new DevicePortalException( (HttpStatusCode)0, "Invalid certificate issuer", null, "Failed to set the device certificate"); } // Install the certificate. CertificateStore trustedStore = CertificateStores.TrustedRootCertificationAuthorities; trustedStore.Add(certificate); } } }
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestGet.cs +2 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ using System; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices.WindowsRuntime; using System.Threading.Tasks; using Windows.Foundation; using Windows.Security.Credentials; Loading Loading @@ -68,7 +69,7 @@ namespace Microsoft.Tools.WindowsDevicePortal } } return null; return (dataBuffer != null) ? dataBuffer.AsStream() : null; } #pragma warning restore 1998 } Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/CertificateHandling.cs +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ namespace Microsoft.Tools.WindowsDevicePortal // Validate the issuer. certificate = new X509Certificate2(certData); if (!certificate.IssuerName.Name.StartsWith(DevicePortalCertificateIssuer)) if (!certificate.IssuerName.Name.Contains(DevicePortalCertificateIssuer)) { certificate = null; throw new DevicePortalException( Loading