6
6
using System . Net . Http ;
7
7
using System . Net . Security ;
8
8
using System . Runtime . InteropServices ;
9
+ using System . Security ;
9
10
// ReSharper disable StringLiteralTypo
10
11
// ReSharper disable UnusedMember.Global
11
12
@@ -53,7 +54,7 @@ private static string GetDefaultUserAgent()
53
54
+ $ "WinAppSDK/{ LauncherConfig . WindowsAppSdkVersion } ";
54
55
}
55
56
56
- public HttpClientBuilder < THandler > UseExternalProxy ( string host , string ? username = null , string ? password = null )
57
+ public HttpClientBuilder < THandler > UseExternalProxy ( string host , string ? username = null , SecureString ? password = null )
57
58
{
58
59
// Try to create the Uri
59
60
if ( Uri . TryCreate ( host , UriKind . Absolute , out Uri ? hostUri ) )
@@ -65,17 +66,16 @@ public HttpClientBuilder<THandler> UseExternalProxy(string host, string? usernam
65
66
IsUseSystemProxy = false ;
66
67
ExternalProxy = null ;
67
68
return this ;
68
-
69
69
}
70
70
71
- public HttpClientBuilder < THandler > UseExternalProxy ( Uri hostUri , string ? username = null , string ? password = null )
71
+ public HttpClientBuilder < THandler > UseExternalProxy ( Uri hostUri , string ? username = null , SecureString ? password = null )
72
72
{
73
73
IsUseSystemProxy = false ;
74
74
75
75
// Initialize the proxy host
76
76
ExternalProxy =
77
77
! string . IsNullOrEmpty ( username )
78
- && ! string . IsNullOrEmpty ( password ) ?
78
+ && password != null ?
79
79
new WebProxy ( hostUri , true , null , new NetworkCredential ( username , password ) )
80
80
: new WebProxy ( hostUri , true ) ;
81
81
@@ -100,7 +100,10 @@ public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = MaxCon
100
100
UseProxy ( ) ;
101
101
102
102
if ( lIsUseProxy && isHttpProxyUrlValid && lProxyUri != null )
103
- UseExternalProxy ( lProxyUri , lHttpProxyUsername , lHttpProxyPassword ) ;
103
+ {
104
+ using SecureString ? proxyPassword = SimpleProtectData . UnprotectStringAsSecureString ( lHttpProxyPassword ) ;
105
+ UseExternalProxy ( lProxyUri , lHttpProxyUsername , proxyPassword ) ;
106
+ }
104
107
105
108
AllowUntrustedCert ( lIsAllowUntrustedCert ) ;
106
109
AllowCookies ( lIsAllowHttpCookies ) ;
0 commit comments