SslStream.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. bool explicitSettings;
  75. IMonoSslStream impl;
  76. internal IMonoSslStream Impl {
  77. get {
  78. CheckDisposed ();
  79. return impl;
  80. }
  81. }
  82. IMonoSslStream2 Impl2 => (IMonoSslStream2)Impl;
  83. internal MonoTlsProvider Provider {
  84. get {
  85. CheckDisposed ();
  86. return provider;
  87. }
  88. }
  89. static MonoTlsProvider GetProvider ()
  90. {
  91. return MonoTlsProviderFactory.GetProvider ();
  92. }
  93. public SslStream (Stream innerStream)
  94. : this (innerStream, false)
  95. {
  96. }
  97. public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
  98. : base (innerStream, leaveInnerStreamOpen)
  99. {
  100. provider = GetProvider ();
  101. settings = MonoTlsSettings.CopyDefaultSettings ();
  102. impl = provider.CreateSslStreamInternal (this, innerStream, leaveInnerStreamOpen, settings);
  103. }
  104. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
  105. : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, null)
  106. {
  107. }
  108. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
  109. : base (innerStream, leaveInnerStreamOpen)
  110. {
  111. provider = GetProvider ();
  112. settings = MonoTlsSettings.CopyDefaultSettings ();
  113. SetAndVerifyValidationCallback (userCertificateValidationCallback);
  114. SetAndVerifySelectionCallback (userCertificateSelectionCallback);
  115. impl = provider.CreateSslStream (innerStream, leaveInnerStreamOpen, settings);
  116. }
  117. [MonoLimitation ("encryptionPolicy is ignored")]
  118. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
  119. : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, userCertificateSelectionCallback)
  120. {
  121. }
  122. internal SslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
  123. : base (innerStream, leaveInnerStreamOpen)
  124. {
  125. this.provider = provider;
  126. this.settings = settings.Clone ();
  127. explicitSettings = true;
  128. impl = provider.CreateSslStreamInternal (this, innerStream, leaveInnerStreamOpen, settings);
  129. }
  130. internal static IMonoSslStream CreateMonoSslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
  131. {
  132. var sslStream = new SslStream (innerStream, leaveInnerStreamOpen, provider, settings);
  133. return sslStream.Impl;
  134. }
  135. void SetAndVerifyValidationCallback (RemoteCertificateValidationCallback callback)
  136. {
  137. if (validationCallback == null) {
  138. validationCallback = callback;
  139. settings.RemoteCertificateValidationCallback = MNS.Private.CallbackHelpers.PublicToMono (callback);
  140. } else if ((callback != null && validationCallback != callback) || (explicitSettings & settings.RemoteCertificateValidationCallback != null)) {
  141. throw new InvalidOperationException (SR.Format (SR.net_conflicting_options, nameof (RemoteCertificateValidationCallback)));
  142. }
  143. }
  144. void SetAndVerifySelectionCallback (LocalCertificateSelectionCallback callback)
  145. {
  146. if (selectionCallback == null) {
  147. selectionCallback = callback;
  148. if (callback == null)
  149. settings.ClientCertificateSelectionCallback = null;
  150. else
  151. settings.ClientCertificateSelectionCallback = (t, lc, rc, ai) => callback (this, t, lc, rc, ai);
  152. } else if ((callback != null && selectionCallback != callback) || (explicitSettings && settings.ClientCertificateSelectionCallback != null)) {
  153. throw new InvalidOperationException (SR.Format (SR.net_conflicting_options, nameof (LocalCertificateSelectionCallback)));
  154. }
  155. }
  156. MNS.MonoSslServerAuthenticationOptions CreateAuthenticationOptions (SslServerAuthenticationOptions sslServerAuthenticationOptions)
  157. {
  158. if (sslServerAuthenticationOptions.ServerCertificate == null && sslServerAuthenticationOptions.ServerCertificateSelectionCallback == null && selectionCallback == null)
  159. throw new ArgumentNullException (nameof (sslServerAuthenticationOptions.ServerCertificate));
  160. if ((sslServerAuthenticationOptions.ServerCertificate != null || selectionCallback != null) && sslServerAuthenticationOptions.ServerCertificateSelectionCallback != null)
  161. throw new InvalidOperationException (SR.Format (SR.net_conflicting_options, nameof (ServerCertificateSelectionCallback)));
  162. var options = new MNS.MonoSslServerAuthenticationOptions (sslServerAuthenticationOptions);
  163. var serverSelectionCallback = sslServerAuthenticationOptions.ServerCertificateSelectionCallback;
  164. if (serverSelectionCallback != null)
  165. options.ServerCertSelectionDelegate = (x) => serverSelectionCallback (this, x);
  166. return options;
  167. }
  168. public virtual void AuthenticateAsClient (string targetHost)
  169. {
  170. Impl.AuthenticateAsClient (targetHost);
  171. }
  172. public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation)
  173. {
  174. Impl.AuthenticateAsClient (targetHost, clientCertificates, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  175. }
  176. public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  177. {
  178. Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
  179. }
  180. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
  181. {
  182. return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
  183. }
  184. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  185. {
  186. return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  187. }
  188. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  189. {
  190. return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  191. }
  192. public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
  193. {
  194. Impl.EndAuthenticateAsClient (asyncResult);
  195. }
  196. public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
  197. {
  198. Impl.AuthenticateAsServer (serverCertificate);
  199. }
  200. public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation)
  201. {
  202. Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  203. }
  204. public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  205. {
  206. Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
  207. }
  208. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
  209. {
  210. return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
  211. }
  212. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  213. {
  214. return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  215. }
  216. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  217. {
  218. return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
  219. }
  220. public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
  221. {
  222. Impl.EndAuthenticateAsServer (asyncResult);
  223. }
  224. public TransportContext TransportContext => null;
  225. public virtual Task AuthenticateAsClientAsync (string targetHost)
  226. {
  227. return Impl.AuthenticateAsClientAsync (targetHost);
  228. }
  229. public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, bool checkCertificateRevocation)
  230. {
  231. return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  232. }
  233. public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  234. {
  235. return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
  236. }
  237. public Task AuthenticateAsClientAsync (SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken)
  238. {
  239. SetAndVerifyValidationCallback (sslClientAuthenticationOptions.RemoteCertificateValidationCallback);
  240. SetAndVerifySelectionCallback (sslClientAuthenticationOptions.LocalCertificateSelectionCallback);
  241. return Impl2.AuthenticateAsClientAsync (new MNS.MonoSslClientAuthenticationOptions (sslClientAuthenticationOptions), cancellationToken);
  242. }
  243. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
  244. {
  245. return Impl.AuthenticateAsServerAsync (serverCertificate);
  246. }
  247. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, bool checkCertificateRevocation)
  248. {
  249. return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, SecurityProtocol.SystemDefaultSecurityProtocols, checkCertificateRevocation);
  250. }
  251. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  252. {
  253. return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
  254. }
  255. public Task AuthenticateAsServerAsync (SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken)
  256. {
  257. return Impl2.AuthenticateAsServerAsync (CreateAuthenticationOptions (sslServerAuthenticationOptions), cancellationToken);
  258. }
  259. public virtual Task ShutdownAsync ()
  260. {
  261. return Impl.ShutdownAsync ();
  262. }
  263. public override bool IsAuthenticated {
  264. get { return Impl.IsAuthenticated; }
  265. }
  266. public override bool IsMutuallyAuthenticated {
  267. get { return Impl.IsMutuallyAuthenticated; }
  268. }
  269. public override bool IsEncrypted {
  270. get { return Impl.IsEncrypted; }
  271. }
  272. public override bool IsSigned {
  273. get { return Impl.IsSigned; }
  274. }
  275. public override bool IsServer {
  276. get { return Impl.IsServer; }
  277. }
  278. public virtual SslProtocols SslProtocol {
  279. get { return (SslProtocols)Impl.SslProtocol; }
  280. }
  281. public virtual bool CheckCertRevocationStatus {
  282. get { return Impl.CheckCertRevocationStatus; }
  283. }
  284. public virtual X509Certificate LocalCertificate {
  285. get { return Impl.LocalCertificate; }
  286. }
  287. public virtual X509Certificate RemoteCertificate {
  288. get { return Impl.RemoteCertificate; }
  289. }
  290. public virtual CipherAlgorithmType CipherAlgorithm {
  291. get { return (CipherAlgorithmType)Impl.CipherAlgorithm; }
  292. }
  293. public virtual int CipherStrength {
  294. get { return Impl.CipherStrength; }
  295. }
  296. public virtual HashAlgorithmType HashAlgorithm {
  297. get { return (HashAlgorithmType)Impl.HashAlgorithm; }
  298. }
  299. public virtual int HashStrength {
  300. get { return Impl.HashStrength; }
  301. }
  302. public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
  303. get { return (ExchangeAlgorithmType)Impl.KeyExchangeAlgorithm; }
  304. }
  305. public virtual int KeyExchangeStrength {
  306. get { return Impl.KeyExchangeStrength; }
  307. }
  308. public SslApplicationProtocol NegotiatedApplicationProtocol {
  309. get {
  310. throw new PlatformNotSupportedException ("https://github.com/mono/mono/issues/12880");
  311. }
  312. }
  313. public override bool CanSeek {
  314. get { return false; }
  315. }
  316. public override bool CanRead {
  317. get { return impl != null && impl.CanRead; }
  318. }
  319. public override bool CanTimeout {
  320. get { return InnerStream.CanTimeout; }
  321. }
  322. public override bool CanWrite {
  323. get { return impl != null && impl.CanWrite; }
  324. }
  325. public override int ReadTimeout {
  326. get { return Impl.ReadTimeout; }
  327. set { Impl.ReadTimeout = value; }
  328. }
  329. public override int WriteTimeout {
  330. get { return Impl.WriteTimeout; }
  331. set { Impl.WriteTimeout = value; }
  332. }
  333. public override long Length {
  334. get { return Impl.Length; }
  335. }
  336. public override long Position {
  337. get { return Impl.Position; }
  338. set {
  339. throw new NotSupportedException (SR.GetString (SR.net_noseek));
  340. }
  341. }
  342. public override void SetLength (long value)
  343. {
  344. Impl.SetLength (value);
  345. }
  346. public override long Seek (long offset, SeekOrigin origin)
  347. {
  348. throw new NotSupportedException (SR.GetString (SR.net_noseek));
  349. }
  350. public override Task FlushAsync (CancellationToken cancellationToken)
  351. {
  352. return InnerStream.FlushAsync (cancellationToken);
  353. }
  354. public override void Flush ()
  355. {
  356. InnerStream.Flush ();
  357. }
  358. void CheckDisposed ()
  359. {
  360. if (impl == null)
  361. throw new ObjectDisposedException ("SslStream");
  362. }
  363. protected override void Dispose (bool disposing)
  364. {
  365. try {
  366. if (impl != null && disposing) {
  367. impl.Dispose ();
  368. impl = null;
  369. }
  370. } finally {
  371. base.Dispose (disposing);
  372. }
  373. }
  374. public override int Read (byte[] buffer, int offset, int count)
  375. {
  376. return Impl.Read (buffer, offset, count);
  377. }
  378. public void Write (byte[] buffer)
  379. {
  380. Impl.Write (buffer);
  381. }
  382. public override void Write (byte[] buffer, int offset, int count)
  383. {
  384. Impl.Write (buffer, offset, count);
  385. }
  386. // [HostProtection (ExternalThreading=true)]
  387. public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  388. {
  389. return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
  390. }
  391. public override int EndRead (IAsyncResult asyncResult)
  392. {
  393. return Impl.EndRead (asyncResult);
  394. }
  395. // [HostProtection (ExternalThreading=true)]
  396. public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  397. {
  398. return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
  399. }
  400. public override void EndWrite (IAsyncResult asyncResult)
  401. {
  402. Impl.EndWrite (asyncResult);
  403. }
  404. #else // !SECURITY_DEP
  405. const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
  406. public SslStream (Stream innerStream)
  407. : this (innerStream, false)
  408. {
  409. }
  410. public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
  411. : base (innerStream, leaveInnerStreamOpen)
  412. {
  413. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  414. }
  415. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
  416. : this (innerStream, leaveInnerStreamOpen)
  417. {
  418. }
  419. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
  420. : this (innerStream, leaveInnerStreamOpen)
  421. {
  422. }
  423. public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
  424. : this (innerStream, leaveInnerStreamOpen)
  425. {
  426. }
  427. public virtual void AuthenticateAsClient (string targetHost)
  428. {
  429. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  430. }
  431. public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  432. {
  433. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  434. }
  435. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
  436. {
  437. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  438. }
  439. public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  440. {
  441. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  442. }
  443. public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
  444. {
  445. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  446. }
  447. public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
  448. {
  449. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  450. }
  451. public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  452. {
  453. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  454. }
  455. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
  456. {
  457. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  458. }
  459. public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
  460. {
  461. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  462. }
  463. public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
  464. {
  465. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  466. }
  467. public TransportContext TransportContext {
  468. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  469. }
  470. public virtual Task AuthenticateAsClientAsync (string targetHost)
  471. {
  472. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  473. }
  474. public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  475. {
  476. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  477. }
  478. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
  479. {
  480. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  481. }
  482. public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
  483. {
  484. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  485. }
  486. public override bool IsAuthenticated {
  487. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  488. }
  489. public override bool IsMutuallyAuthenticated {
  490. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  491. }
  492. public override bool IsEncrypted {
  493. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  494. }
  495. public override bool IsSigned {
  496. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  497. }
  498. public override bool IsServer {
  499. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  500. }
  501. public virtual SslProtocols SslProtocol {
  502. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  503. }
  504. public virtual bool CheckCertRevocationStatus {
  505. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  506. }
  507. public virtual X509Certificate LocalCertificate {
  508. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  509. }
  510. public virtual X509Certificate RemoteCertificate {
  511. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  512. }
  513. public virtual CipherAlgorithmType CipherAlgorithm {
  514. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  515. }
  516. public virtual int CipherStrength {
  517. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  518. }
  519. public virtual HashAlgorithmType HashAlgorithm {
  520. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  521. }
  522. public virtual int HashStrength {
  523. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  524. }
  525. public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
  526. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  527. }
  528. public virtual int KeyExchangeStrength {
  529. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  530. }
  531. public SslApplicationProtocol NegotiatedApplicationProtocol {
  532. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  533. }
  534. public override bool CanSeek {
  535. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  536. }
  537. public override bool CanRead {
  538. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  539. }
  540. public override bool CanTimeout {
  541. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  542. }
  543. public override bool CanWrite {
  544. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  545. }
  546. public override int ReadTimeout {
  547. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  548. set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  549. }
  550. public override int WriteTimeout {
  551. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  552. set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  553. }
  554. public override long Length {
  555. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  556. }
  557. public override long Position {
  558. get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  559. set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
  560. }
  561. public override void SetLength (long value)
  562. {
  563. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  564. }
  565. public override long Seek (long offset, SeekOrigin origin)
  566. {
  567. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  568. }
  569. public override void Flush ()
  570. {
  571. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  572. }
  573. protected override void Dispose (bool disposing)
  574. {
  575. }
  576. public override int Read (byte[] buffer, int offset, int count)
  577. {
  578. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  579. }
  580. public void Write (byte[] buffer)
  581. {
  582. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  583. }
  584. public override void Write (byte[] buffer, int offset, int count)
  585. {
  586. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  587. }
  588. public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  589. {
  590. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  591. }
  592. public override int EndRead (IAsyncResult asyncResult)
  593. {
  594. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  595. }
  596. public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
  597. {
  598. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  599. }
  600. public override void EndWrite (IAsyncResult asyncResult)
  601. {
  602. throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
  603. }
  604. #endif
  605. }
  606. }