1- using System ;
1+ using System ;
22using System . Threading . Tasks ;
33using System . Net ;
44using System . IO ;
99using System . Linq ;
1010using Newtonsoft . Json ;
1111using OutlineManagerExceptions ;
12+ using System . Net . Security ;
13+ using System . Security . Cryptography . X509Certificates ;
1214
1315namespace OutlineManager
1416{
@@ -54,7 +56,7 @@ private static bool CallRequest(string urlMethod, string method, out string data
5456 }
5557 return true ;
5658 }
57- catch ( WebException exc )
59+ catch ( WebException exc )
5860 {
5961 data = null ;
6062 if ( exc . Message == "The SSL connection could not be established, see inner exception." )
@@ -73,12 +75,12 @@ private static bool CallRequest(string urlMethod, string method, JObject args, o
7375 {
7476 WebClient webClient = new WebClient ( ) ;
7577 webClient . Headers [ HttpRequestHeader . ContentType ] = "application/json" ;
76- if ( HasSsl == false )
77- ServicePointManager . SecurityProtocol = SecurityProtocolType . Tls12 ;
78+ if ( HasSsl == false )
79+ ServicePointManager . ServerCertificateValidationCallback = ( object sender , X509Certificate certificate , X509Chain chain , SslPolicyErrors sslPolicyErrors ) => true ;
7880 data = webClient . UploadString ( $ "{ ApiUrl } /{ urlMethod } ", method , args . ToString ( ) ) ;
7981 return true ;
8082 }
81- catch ( WebException exc )
83+ catch ( WebException exc )
8284 {
8385 data = null ;
8486 if ( exc . Message == "The SSL connection could not be established, see inner exception." )
@@ -97,46 +99,51 @@ private static bool CallRequest(string urlMethod, string method, JObject args, o
9799 /// </summary>
98100 /// <returns>Outline Server Info in <see cref="T:OutlineManager.Types.OutlineServer" /></returns>
99101 /// <exception cref="OutlineManagerException"></exception>
100- public OutlineServer GetOutlineServer ( ) {
102+ public OutlineServer GetOutlineServer ( )
103+ {
101104 CallRequest ( "server" , "GET" , out var data ) ;
102105 return JsonConvert . DeserializeObject < OutlineServer > ( data ) ;
103106 }
104-
107+
105108 ///<summary>
106109 /// Changes the hostname for access keys.
107110 /// Must be a valid hostname or IP address.
108111 /// If it's a hostname, DNS must be set up independently of this API.
109112 ///</summary>
110113 /// <returns><b>True</b>, if the hostname was changed succesfully</returns>
111- public bool ChangeHostname ( string newHostname ) {
112- return CallRequest ( "server/hostname-for-access-keys" , "PUT" , new JObject { { "hostname" , newHostname } } , out _ ) ;
114+ public bool ChangeHostname ( string newHostname )
115+ {
116+ return CallRequest ( "server/hostname-for-access-keys" , "PUT" , new JObject { { "hostname" , newHostname } } , out _ ) ;
113117 }
114-
118+
115119 ///<summary>
116120 /// Changes the default port for newly created access keys.
117121 /// This can be a port already used for access keys.
118122 ///</summary>
119123 /// <returns><b>True</b>, if the port was changed succesfully</returns>
120- public bool ChangePort ( int newPort ) {
121- return CallRequest ( "server/port-for-new-access-keys" , "PUT" , new JObject { { "port" , newPort } } , out _ ) ;
124+ public bool ChangePort ( int newPort )
125+ {
126+ return CallRequest ( "server/port-for-new-access-keys" , "PUT" , new JObject { { "port" , newPort } } , out _ ) ;
122127 }
123-
128+
124129 ///<summary>
125130 /// Rename the Outline Server
126131 ///</summary>
127132 /// <returns><b>True</b>, if the server name was changed succesfully</returns>
128- public bool RenameServer ( string newName ) {
129- return CallRequest ( "name" , "PUT" , new JObject { { "name" , newName } } , out _ ) ;
133+ public bool RenameServer ( string newName )
134+ {
135+ return CallRequest ( "name" , "PUT" , new JObject { { "name" , newName } } , out _ ) ;
130136 }
131-
137+
132138 ///<summary>
133139 /// Change Metrics Sharing
134140 ///</summary>
135141 /// <returns><b>True</b>, if the metrics sharing was changed succesfully</returns>
136- public bool ChangeMetricsSharing ( bool newParam ) {
137- return CallRequest ( "metrics/enabled" , "PUT" , new JObject { { "metricsEnabled" , newParam } } , out _ ) ;
142+ public bool ChangeMetricsSharing ( bool newParam )
143+ {
144+ return CallRequest ( "metrics/enabled" , "PUT" , new JObject { { "metricsEnabled" , newParam } } , out _ ) ;
138145 }
139-
146+
140147 /// <summary>
141148 /// Get Outline key in <see cref="T:OutlineManager.Types.OutlineKey" /> by ID
142149 /// </summary>
0 commit comments