Commit 470af055 authored by Jason Williams's avatar Jason Williams
Browse files

Update the messaging around the UWP sample app's cert support

parent 01b5c02a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
        <Button x:Name="rebootDevice" Content="Reboot" Grid.Column="0" HorizontalAlignment="Left" Margin="114,123,0,0" VerticalAlignment="Top" Width="93" Click="RebootDevice_Click" IsEnabled="False" Height="32"/>
        <Button x:Name="shutdownDevice" Content="Shutdown" Grid.Column="0" HorizontalAlignment="Left" Margin="212,123,0,0" VerticalAlignment="Top" Width="93" Click="ShutdownDevice_Click" IsEnabled="False" Height="32"/>

        <TextBlock x:Name="UnsecureCertWarning" Grid.Column="0" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" FontSize="16" Margin="12,231,0,0" Height="60" Text="Note: The UWP Sample App does not currently support certificate validation for HTTPS communication" />

        <Border Grid.Column="0" BorderBrush="Black" BorderThickness="1" Height="1" Margin="15,160,15,0" VerticalAlignment="Top"/>

        <Button x:Name="getIPConfig" Content="Get IP Config" Grid.Column="0" HorizontalAlignment="Left" Margin="12,166,0,0" VerticalAlignment="Top" Width="144" Click="GetIPConfig_Click" IsEnabled="False"/>
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ namespace SampleWdpClient.UniversalWindows
                        };

                        // TODO: Support proper certificate validation instead of blindly trusting this cert (Issue #154/#145).
                        await portal.GetDeviceCertificate();
                        await portal.GetRootDeviceCertificate(true);
                        await portal.Connect();

                        this.MarshalUpdateCommandOutput(sb.ToString());
+7 −2
Original line number Diff line number Diff line
@@ -23,9 +23,10 @@ namespace Microsoft.Tools.WindowsDevicePortal
        /// <summary>
        /// Gets the root certificate from the device.
        /// </summary>
        /// <param name="acceptUntrustedCerts">Whether or not we should accept untrusted certificates.</param>
        /// <returns>The device certificate.</returns>
#pragma warning disable 1998
        public async Task<Certificate> GetDeviceCertificate()
        public async Task<Certificate> GetRootDeviceCertificate(bool acceptUntrustedCerts = false)
        {
            Certificate certificate = null;
            bool useHttps = true;
@@ -48,9 +49,13 @@ namespace Microsoft.Tools.WindowsDevicePortal
                try
                {
                    HttpBaseProtocolFilter requestSettings = new HttpBaseProtocolFilter();
                    requestSettings.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
                    requestSettings.AllowUI = false;

                    if (acceptUntrustedCerts)
                    {
                        requestSettings.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
                    }

                    using (HttpClient client = new HttpClient(requestSettings))
                    {
                        this.ApplyHttpHeaders(client, HttpMethods.Get);