1
- using CollapseLauncher . Helper . Update ;
1
+ using CollapseLauncher . Helper . Update ;
2
2
using Hi3Helper . Shared . Region ;
3
3
using System ;
4
4
using System . Collections . Generic ;
5
5
using System . Net ;
6
6
using System . Net . Http ;
7
7
using System . Net . Security ;
8
8
using System . Runtime . InteropServices ;
9
- using System . Threading ;
9
+ using System . Security ;
10
10
// ReSharper disable StringLiteralTypo
11
11
// ReSharper disable UnusedMember.Global
12
12
// ReSharper disable CheckNamespace
@@ -58,7 +58,7 @@ private static string GetDefaultUserAgent()
58
58
+ $ "WinAppSDK/{ LauncherConfig . WindowsAppSdkVersion } ";
59
59
}
60
60
61
- public HttpClientBuilder < THandler > UseExternalProxy ( string host , string ? username = null , string ? password = null )
61
+ public HttpClientBuilder < THandler > UseExternalProxy ( string host , string ? username = null , SecureString ? password = null )
62
62
{
63
63
// Try to create the Uri
64
64
if ( Uri . TryCreate ( host , UriKind . Absolute , out Uri ? hostUri ) )
@@ -70,17 +70,16 @@ public HttpClientBuilder<THandler> UseExternalProxy(string host, string? usernam
70
70
IsUseSystemProxy = false ;
71
71
ExternalProxy = null ;
72
72
return this ;
73
-
74
73
}
75
74
76
- public HttpClientBuilder < THandler > UseExternalProxy ( Uri hostUri , string ? username = null , string ? password = null )
75
+ public HttpClientBuilder < THandler > UseExternalProxy ( Uri hostUri , string ? username = null , SecureString ? password = null )
77
76
{
78
77
IsUseSystemProxy = false ;
79
78
80
79
// Initialize the proxy host
81
80
ExternalProxy =
82
81
! string . IsNullOrEmpty ( username )
83
- && ! string . IsNullOrEmpty ( password ) ?
82
+ && password != null ?
84
83
new WebProxy ( hostUri , true , null , new NetworkCredential ( username , password ) )
85
84
: new WebProxy ( hostUri , true ) ;
86
85
@@ -107,7 +106,8 @@ public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = MaxCon
107
106
108
107
if ( lIsUseProxy && isHttpProxyUrlValid && lProxyUri != null )
109
108
{
110
- UseExternalProxy ( lProxyUri , lHttpProxyUsername , lHttpProxyPassword ) ;
109
+ using SecureString ? proxyPassword = SimpleProtectData . UnprotectStringAsSecureString ( lHttpProxyPassword ) ;
110
+ UseExternalProxy ( lProxyUri , lHttpProxyUsername , proxyPassword ) ;
111
111
}
112
112
113
113
lock ( HttpClientBuilderSharedLock )
0 commit comments