SslStream.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. //
  2. // SslStream.cs
  3. //
  4. // Author:
  5. // Martin Baulig <[email protected]>
  6. //
  7. // Copyright (c) 2015 Xamarin, Inc.
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining a copy
  10. // of this software and associated documentation files (the "Software"), to deal
  11. // in the Software without restriction, including without limitation the rights
  12. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. // copies of the Software, and to permit persons to whom the Software is
  14. // furnished to do so, subject to the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be included in
  17. // all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. // THE SOFTWARE.
  26. #if SECURITY_DEP
  27. #if MONO_SECURITY_ALIAS
  28. extern alias MonoSecurity;
  29. #endif
  30. #if MONO_SECURITY_ALIAS
  31. using MonoSecurity::Mono.Security.Interface;
  32. #else
  33. using Mono.Security.Interface;
  34. #endif
  35. using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
  36. using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
  37. using ExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
  38. #endif
  39. using System.IO;
  40. using System.Net;
  41. using System.Net.Security;
  42. using System.Security.Authentication;
  43. using System.Security.Cryptography.X509Certificates;
  44. using System.Security.Permissions;
  45. using System.Security.Principal;
  46. using System.Security.Cryptography;
  47. using System.Threading;
  48. using System.Threading.Tasks;
  49. using MNS = Mono.Net.Security;
  50. namespace System.Net.Security
  51. {
  52. public delegate X509Certificate ServerCertificateSelectionCallback (object sender, string hostName);
  53. /*
  54. * Internal delegates from the referencesource / corefx.
  55. */
  56. internal delegate bool RemoteCertValidationCallback (
  57. string host,
  58. X509Certificate certificate,
  59. X509Chain chain,
  60. SslPolicyErrors sslPolicyErrors);
  61. internal delegate X509Certificate LocalCertSelectionCallback (
  62. string targetHost,
  63. X509CertificateCollection localCertificates,
  64. X509Certificate remoteCertificate,
  65. string[] acceptableIssuers);
  66. internal delegate X509Certificate ServerCertSelectionCallback (string hostName);
  67. public class SslStream : AuthenticatedStream
  68. {
  69. #if SECURITY_DEP
  70. MonoTlsProvider provider;
  71. MonoTlsSettings settings;
  72. RemoteCertificateValidationCallback validationCallback;
  73. LocalCertificateSelectionCallback selectionCallback;
  74. IMonoSslStream impl;
  75. internal IMonoSslStream Impl {
  76. get {
  77. CheckDisposed ();
  78. return impl;
  79. }
  80. }
  81. IMonoSslStream2 Impl2 => (IMonoSslStream2)Impl;
  82. internal MonoTlsProvider Provider {
  83. get {
  84. CheckDisposed ();
  85. return provider;
  86. }
  87. }
  88. static MonoTlsProvider GetProvider ()
  89. {
  90. return MonoTlsProviderFactory.GetProvider ();
  91. }
  92. public SslStream (Stream innerStream)
  93. : this (innerStream, false)
  94. {
  95. }
  96. public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
  97. : base (innerStream, leaveInnerStreamOpen)
  98. {
  99. provider = GetProvider ();
  100. settings = MonoTlsSettings.CopyDefaultSettings ();
  101. impl = provider.CreateSslStreamInternal (this, innerStream, leaveInnerStreamOpen, settings);
  102. }
  103. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
  104. : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, null)
  105. {
  106. }
  107. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
  108. : base (innerStream, leaveInnerStreamOpen)
  109. {
  110. provider = GetProvider ();
  111. settings = MonoTlsSettings.CopyDefaultSettings ();
  112. SetAndVerifyValidationCallback (userCertificateValidationCallback);
  113. SetAndVerifySelectionCallback (userCertificateSelectionCallback);
  114. impl = provider.CreateSslStream (innerStream, leaveInnerStreamOpen, settings);
  115. }
  116. [MonoLimitation ("encryptionPolicy is ignored")]
  117. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
  118. : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, userCertificateSelectionCallback)
  119. {
  120. }
  121. internal SslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
  122. : base (innerStream, leaveInnerStreamOpen)
  123. {
  124. this.provider = provider;
  125. this.settings = settings.Clone ();
  126. impl = provider.CreateSslStreamInternal (this, innerStream, leaveInnerStreamOpen, settings);
  127. }
  128. internal static IMonoSslStream CreateMonoSslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
  129. {
  130. var sslStream = new SslStream (innerStream, leaveInnerStreamOpen, provider, settings);
  131. return sslStream.Impl;
  132. }
  133. void SetAndVerifyValidationCallback (RemoteCertificateValidationCallback callback)
  134. {
  135. if (validationCallback == null) {
  136. validationCallback = callback;
  137. settings.RemoteCertificateValidationCallback = MNS.Private.CallbackHelpers.PublicToMono (callback);
  138. } else if (callback != null && validationCallback != callback) {
  139. throw new InvalidOperationException (SR.Format (SR.net_conflicting_options, nameof (RemoteCertificateValidationCallback)));
  140. }
  141. }
  142. void SetAndVerifySelectionCallback (LocalCertificateSelectionCallback callback)
  143. {
  144. if (selectionCallback == null) {
  145. selectionCallback = callback;
  146. settings.ClientCertificateSelectionCallback = MNS.Private.CallbackHelpers.PublicToMono (callback);
  147. } else if (callback != null && selectionCallback != callback) {
  148. throw new InvalidOperationException (SR.Format (SR.net_conflicting_options, nameof (LocalCertificateSelectionCallback)));
  149. }
  150. }
  151. public virtual void AuthenticateAsClient (string targetHost)
  152. {
  153. Impl.AuthenticateAsClient (targetHost);
  154. }
  155. public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation)
  156. {
  157. Impl.AuthenticateAsClient (targetHost, clientCertificates, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  158. }
  159. public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  160. {
  161. Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
  162. }
  163. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
  164. {
  165. return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
  166. }
  167. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  168. {
  169. return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  170. }
  171. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  172. {
  173. return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  174. }
  175. public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
  176. {
  177. Impl.EndAuthenticateAsClient (asyncResult);
  178. }
  179. public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
  180. {
  181. Impl.AuthenticateAsServer (serverCertificate);
  182. }
  183. public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation)
  184. {
  185. Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  186. }
  187. public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  188. {
  189. Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
  190. }
  191. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
  192. {
  193. return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
  194. }
  195. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  196. {
  197. return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  198. }
  199. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  200. {
  201. return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  202. }
  203. public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
  204. {
  205. Impl.EndAuthenticateAsServer (asyncResult);
  206. }
  207. public TransportContext TransportContext => null;
  208. public virtual Task AuthenticateAsClientAsync (string targetHost)
  209. {
  210. return Impl.AuthenticateAsClientAsync (targetHost);
  211. }
  212. public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation)
  213. {
  214. return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  215. }
  216. public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  217. {
  218. return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
  219. }
  220. public Task AuthenticateAsClientAsync (SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken)
  221. {
  222. SetAndVerifyValidationCallback (sslClientAuthenticationOptions.RemoteCertificateValidationCallback);
  223. SetAndVerifySelectionCallback (sslClientAuthenticationOptions.LocalCertificateSelectionCallback);
  224. return Impl2.AuthenticateAsClientAsync (new MNS.MonoSslClientAuthenticationOptions (sslClientAuthenticationOptions), cancellationToken);
  225. }
  226. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
  227. {
  228. return Impl.AuthenticateAsServerAsync (serverCertificate);
  229. }
  230. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation)
  231. {
  232. return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  233. }
  234. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  235. {
  236. return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
  237. }
  238. public Task AuthenticateAsServerAsync (SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken)
  239. {
  240. return Impl2.AuthenticateAsServerAsync (new MNS.MonoSslServerAuthenticationOptions (sslServerAuthenticationOptions), cancellationToken);
  241. }
  242. public virtual Task ShutdownAsync ()
  243. {
  244. return Impl.ShutdownAsync ();
  245. }
  246. public override bool IsAuthenticated {
  247. get { return Impl.IsAuthenticated; }
  248. }
  249. public override bool IsMutuallyAuthenticated {
  250. get { return Impl.IsMutuallyAuthenticated; }
  251. }
  252. public override bool IsEncrypted {
  253. get { return Impl.IsEncrypted; }
  254. }
  255. public override bool IsSigned {
  256. get { return Impl.IsSigned; }
  257. }
  258. public override bool IsServer {
  259. get { return Impl.IsServer; }
  260. }
  261. public virtual SslProtocols SslProtocol {
  262. get { return (SslProtocols)Impl.SslProtocol; }
  263. }
  264. public virtual bool CheckCertRevocationStatus {
  265. get { return Impl.CheckCertRevocationStatus; }
  266. }
  267. public virtual X509Certificate LocalCertificate {
  268. get { return Impl.LocalCertificate; }
  269. }
  270. public virtual X509Certificate RemoteCertificate {
  271. get { return Impl.RemoteCertificate; }
  272. }
  273. public virtual CipherAlgorithmType CipherAlgorithm {
  274. get { return (CipherAlgorithmType)Impl.CipherAlgorithm; }
  275. }
  276. public virtual int CipherStrength {
  277. get { return Impl.CipherStrength; }
  278. }
  279. public virtual HashAlgorithmType HashAlgorithm {
  280. get { return (HashAlgorithmType)Impl.HashAlgorithm; }
  281. }
  282. public virtual int HashStrength {
  283. get { return Impl.HashStrength; }
  284. }
  285. public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
  286. get { return (ExchangeAlgorithmType)Impl.KeyExchangeAlgorithm; }
  287. }
  288. public virtual int KeyExchangeStrength {
  289. get { return Impl.KeyExchangeStrength; }
  290. }
  291. public override bool CanSeek {
  292. get { return false; }
  293. }
  294. public override bool CanRead {
  295. get { return impl != null && impl.CanRead; }
  296. }
  297. public override bool CanTimeout {
  298. get { return InnerStream.CanTimeout; }
  299. }
  300. public override bool CanWrite {
  301. get { return impl != null && impl.CanWrite; }
  302. }
  303. public override int ReadTimeout {
  304. get { return Impl.ReadTimeout; }
  305. set { Impl.ReadTimeout = value; }
  306. }
  307. public override int WriteTimeout {
  308. get { return Impl.WriteTimeout; }
  309. set { Impl.WriteTimeout = value; }
  310. }
  311. public override long Length {
  312. get { return Impl.Length; }
  313. }
  314. public override long Position {
  315. get { return Impl.Position; }
  316. set {
  317. throw new NotSupportedException (SR.GetString (SR.net_noseek));
  318. }
  319. }
  320. public override void SetLength (long value)
  321. {
  322. Impl.SetLength (value);
  323. }
  324. public override long Seek (long offset, SeekOrigin origin)
  325. {
  326. throw new NotSupportedException (SR.GetString (SR.net_noseek));
  327. }
  328. public override Task FlushAsync (CancellationToken cancellationToken)
  329. {
  330. return InnerStream.FlushAsync (cancellationToken);
  331. }
  332. public override void Flush ()
  333. {
  334. InnerStream.Flush ();
  335. }
  336. void CheckDisposed ()
  337. {
  338. if (impl == null)
  339. throw new ObjectDisposedException ("SslStream");
  340. }
  341. protected override void Dispose (bool disposing)
  342. {
  343. try {
  344. if (impl != null && disposing) {
  345. impl.Dispose ();
  346. impl = null;
  347. }
  348. } finally {
  349. base.Dispose (disposing);
  350. }
  351. }
  352. public override int Read (byte[] buffer, int offset, int count)
  353. {
  354. return Impl.Read (buffer, offset, count);
  355. }
  356. public void Write (byte[] buffer)
  357. {
  358. Impl.Write (buffer);
  359. }
  360. public override void Write (byte[] buffer, int offset, int count)
  361. {
  362. Impl.Write (buffer, offset, count);
  363. }
  364. // [HostProtection (ExternalThreading=true)]
  365. public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  366. {
  367. return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
  368. }
  369. public override int EndRead (IAsyncResult asyncResult)
  370. {
  371. return Impl.EndRead (asyncResult);
  372. }
  373. // [HostProtection (ExternalThreading=true)]
  374. public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  375. {
  376. return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
  377. }
  378. public override void EndWrite (IAsyncResult asyncResult)
  379. {
  380. Impl.EndWrite (asyncResult);
  381. }
  382. #else // !SECURITY_DEP
  383. const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
  384. public SslStream (Stream innerStream)
  385. : this (innerStream, false)
  386. {
  387. }
  388. public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
  389. : base (innerStream, leaveInnerStreamOpen)
  390. {
  391. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  392. }
  393. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
  394. : this (innerStream, leaveInnerStreamOpen)
  395. {
  396. }
  397. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
  398. : this (innerStream, leaveInnerStreamOpen)
  399. {
  400. }
  401. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
  402. : this (innerStream, leaveInnerStreamOpen)
  403. {
  404. }
  405. public virtual void AuthenticateAsClient (string targetHost)
  406. {
  407. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  408. }
  409. public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  410. {
  411. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  412. }
  413. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
  414. {
  415. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  416. }
  417. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  418. {
  419. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  420. }
  421. public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
  422. {
  423. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  424. }
  425. public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
  426. {
  427. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  428. }
  429. public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  430. {
  431. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  432. }
  433. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
  434. {
  435. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  436. }
  437. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  438. {
  439. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  440. }
  441. public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
  442. {
  443. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  444. }
  445. public TransportContext TransportContext {
  446. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  447. }
  448. public virtual Task AuthenticateAsClientAsync (string targetHost)
  449. {
  450. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  451. }
  452. public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  453. {
  454. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  455. }
  456. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
  457. {
  458. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  459. }
  460. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  461. {
  462. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  463. }
  464. public override bool IsAuthenticated {
  465. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  466. }
  467. public override bool IsMutuallyAuthenticated {
  468. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  469. }
  470. public override bool IsEncrypted {
  471. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  472. }
  473. public override bool IsSigned {
  474. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  475. }
  476. public override bool IsServer {
  477. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  478. }
  479. public virtual SslProtocols SslProtocol {
  480. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  481. }
  482. public virtual bool CheckCertRevocationStatus {
  483. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  484. }
  485. public virtual X509Certificate LocalCertificate {
  486. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  487. }
  488. public virtual X509Certificate RemoteCertificate {
  489. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  490. }
  491. public virtual CipherAlgorithmType CipherAlgorithm {
  492. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  493. }
  494. public virtual int CipherStrength {
  495. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  496. }
  497. public virtual HashAlgorithmType HashAlgorithm {
  498. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  499. }
  500. public virtual int HashStrength {
  501. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  502. }
  503. public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
  504. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  505. }
  506. public virtual int KeyExchangeStrength {
  507. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  508. }
  509. public override bool CanSeek {
  510. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  511. }
  512. public override bool CanRead {
  513. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  514. }
  515. public override bool CanTimeout {
  516. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  517. }
  518. public override bool CanWrite {
  519. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  520. }
  521. public override int ReadTimeout {
  522. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  523. set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  524. }
  525. public override int WriteTimeout {
  526. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  527. set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  528. }
  529. public override long Length {
  530. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  531. }
  532. public override long Position {
  533. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  534. set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  535. }
  536. public override void SetLength (long value)
  537. {
  538. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  539. }
  540. public override long Seek (long offset, SeekOrigin origin)
  541. {
  542. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  543. }
  544. public override void Flush ()
  545. {
  546. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  547. }
  548. protected override void Dispose (bool disposing)
  549. {
  550. }
  551. public override int Read (byte[] buffer, int offset, int count)
  552. {
  553. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  554. }
  555. public void Write (byte[] buffer)
  556. {
  557. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  558. }
  559. public override void Write (byte[] buffer, int offset, int count)
  560. {
  561. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  562. }
  563. public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  564. {
  565. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  566. }
  567. public override int EndRead (IAsyncResult asyncResult)
  568. {
  569. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  570. }
  571. public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  572. {
  573. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  574. }
  575. public override void EndWrite (IAsyncResult asyncResult)
  576. {
  577. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  578. }
  579. #endif
  580. }
  581. }