TlsServer.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Collections;
  5. using System.IO;
  6. using BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto;
  7. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls
  8. {
  9. /// <summary>Interface describing a TLS server endpoint.</summary>
  10. public interface TlsServer
  11. : TlsPeer
  12. {
  13. void Init(TlsServerContext context);
  14. /// <summary>Return the specified session, if available.</summary>
  15. /// <remarks>
  16. /// Note that the peer's certificate chain for the session (if any) may need to be periodically revalidated.
  17. /// </remarks>
  18. /// <param name="sessionID">the ID of the session to resume.</param>
  19. /// <returns>A <see cref="TlsSession"/> with the specified session ID, or null.</returns>
  20. /// <seealso cref="SessionParameters.PeerCertificate"/>
  21. TlsSession GetSessionToResume(byte[] sessionID);
  22. byte[] GetNewSessionID();
  23. /// <summary>Return the <see cref="TlsPskExternal">external PSK</see> to select from the ClientHello.</summary>
  24. /// <remarks>
  25. /// WARNING: EXPERIMENTAL FEATURE, UNSTABLE API
  26. /// Note that this will only be called when TLS 1.3 or higher is amongst the offered protocol versions, and one
  27. /// or more PSKs are actually offered.
  28. /// </remarks>
  29. /// <param name="identities">an <see cref="IList"/> of <see cref="PskIdentity"/> instances.</param>
  30. /// <returns>The <see cref="TlsPskExternal"/> corresponding to the selected identity, or null to not select
  31. /// any.</returns>
  32. TlsPskExternal GetExternalPsk(IList identities);
  33. void NotifySession(TlsSession session);
  34. /// <exception cref="IOException"/>
  35. void NotifyClientVersion(ProtocolVersion clientVersion);
  36. /// <exception cref="IOException"/>
  37. void NotifyFallback(bool isFallback);
  38. /// <exception cref="IOException"/>
  39. void NotifyOfferedCipherSuites(int[] offeredCipherSuites);
  40. /// <param name="clientExtensions">(Int32 -> byte[])</param>
  41. /// <exception cref="IOException"/>
  42. void ProcessClientExtensions(IDictionary clientExtensions);
  43. /// <exception cref="IOException"/>
  44. ProtocolVersion GetServerVersion();
  45. /// <exception cref="IOException"/>
  46. int[] GetSupportedGroups();
  47. /// <exception cref="IOException"/>
  48. int GetSelectedCipherSuite();
  49. /// <returns>(Int32 -> byte[])</returns>
  50. /// <exception cref="IOException"/>
  51. IDictionary GetServerExtensions();
  52. /// <param name="serverExtensions">(Int32 -> byte[])</param>
  53. /// <exception cref="IOException"/>
  54. void GetServerExtensionsForConnection(IDictionary serverExtensions);
  55. /// <returns>(SupplementalDataEntry)</returns>
  56. /// <exception cref="IOException"/>
  57. IList GetServerSupplementalData();
  58. /// <summary>Return server credentials to use.</summary>
  59. /// <remarks>
  60. /// The returned value may be null, or else it MUST implement <em>exactly one</em> of
  61. /// <see cref="TlsCredentialedAgreement"/>, <see cref="TlsCredentialedDecryptor"/>, or
  62. /// <see cref = "TlsCredentialedSigner"/>, depending on the key exchange that was negotiated.
  63. /// </remarks>
  64. /// <returns>a <see cref="TlsCredentials"/> object or null for anonymous key exchanges.</returns>
  65. /// <exception cref="IOException"/>
  66. TlsCredentials GetCredentials();
  67. /// <remarks>
  68. /// This method will be called (only) if the server included an extension of type "status_request" with empty
  69. /// "extension_data" in the extended server hello. See <i>RFC 3546 3.6. Certificate Status Request</i>. If a
  70. /// non-null <see cref="CertificateStatus"/> is returned, it is sent to the client as a handshake message of
  71. /// type "certificate_status".
  72. /// </remarks>
  73. /// <returns>A <see cref="CertificateStatus"/> to be sent to the client (or null for none).</returns>
  74. /// <exception cref="IOException"/>
  75. CertificateStatus GetCertificateStatus();
  76. /// <exception cref="IOException"/>
  77. CertificateRequest GetCertificateRequest();
  78. /// <exception cref="IOException"/>
  79. TlsPskIdentityManager GetPskIdentityManager();
  80. /// <exception cref="IOException"/>
  81. TlsSrpLoginParameters GetSrpLoginParameters();
  82. /// <exception cref="IOException"/>
  83. TlsDHConfig GetDHConfig();
  84. /// <exception cref="IOException"/>
  85. TlsECConfig GetECDHConfig();
  86. /// <param name="clientSupplementalData">(SupplementalDataEntry)</param>
  87. /// <exception cref="IOException"/>
  88. void ProcessClientSupplementalData(IList clientSupplementalData);
  89. /// <summary>Called by the protocol handler to report the client certificate, only if
  90. /// <see cref="GetCertificateRequest"/> returned non-null.</summary>
  91. /// <remarks>
  92. /// Note: this method is responsible for certificate verification and validation.
  93. /// </remarks>
  94. /// <param name="clientCertificate">the effective client certificate (may be an empty chain).</param>
  95. /// <exception cref="IOException"/>
  96. void NotifyClientCertificate(Certificate clientCertificate);
  97. /// <summary>RFC 5077 3.3. NewSessionTicket Handshake Message.</summary>
  98. /// <remarks>
  99. /// This method will be called (only) if a NewSessionTicket extension was sent by the server. See <i>RFC 5077
  100. /// 4. Recommended Ticket Construction</i> for recommended format and protection.
  101. /// </remarks>
  102. /// <returns>The ticket.</returns>
  103. /// <exception cref="IOException"/>
  104. NewSessionTicket GetNewSessionTicket();
  105. }
  106. }
  107. #pragma warning restore
  108. #endif