TlsClient.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls
  7. {
  8. public interface TlsClient
  9. : TlsPeer
  10. {
  11. void Init(TlsClientContext context);
  12. /// <summary>Return the session this client wants to resume, if any.</summary>
  13. /// <remarks>
  14. /// Note that the peer's certificate chain for the session (if any) may need to be periodically revalidated.
  15. /// </remarks>
  16. /// <returns>A <see cref="TlsSession"/> representing the resumable session to be used for this connection, or
  17. /// null to use a new session.</returns>
  18. /// <seealso cref="SessionParameters.PeerCertificate"/>
  19. TlsSession GetSessionToResume();
  20. /// <summary>Return the <see cref="TlsPskExternal">external PSKs</see> to offer in the ClientHello.</summary>
  21. /// <remarks>This will only be called when TLS 1.3 or higher is amongst the offered protocol versions.</remarks>
  22. /// <returns>an <see cref="IList"/> of <see cref="TlsPskExternal"/> instances, or null if none should be
  23. /// offered.</returns>
  24. IList GetExternalPsks();
  25. bool IsFallback();
  26. /// <returns>(Int32 -> byte[])</returns>
  27. /// <exception cref="IOException"/>
  28. IDictionary GetClientExtensions();
  29. /// <summary>If this client is offering TLS 1.3 or higher, this method may be called to determine for which
  30. /// groups a key share should be included in the initial ClientHello.</summary>
  31. /// <remarks>
  32. /// Groups that were not included in the supported_groups extension (by <see cref="GetClientExtensions"/> will
  33. /// be ignored. The protocol will then add a suitable key_share extension to the ClientHello extensions.
  34. /// </remarks>
  35. /// <returns>an <see cref="IList"/> of <see cref="NamedGroup">named group</see> values, possibly empty or null.
  36. /// </returns>
  37. IList GetEarlyKeyShareGroups();
  38. /// <exception cref="IOException"/>
  39. void NotifyServerVersion(ProtocolVersion selectedVersion);
  40. /// <summary>Notifies the client of the session that will be offered in ClientHello for resumption, if any.
  41. /// </summary>
  42. /// <remarks>
  43. /// This will be either the session returned from {@link #getSessionToResume()} or null if that session was
  44. /// unusable. NOTE: the actual negotiated session_id is notified by <see cref="NotifySessionID(byte[])"/>.
  45. /// </remarks>
  46. /// <param name="session">The <see cref="TlsSession"/> representing the resumable session to be offered for
  47. /// this connection, or null if there is none.</param>
  48. /// <seealso cref="NotifySessionID(byte[])"/>
  49. void NotifySessionToResume(TlsSession session);
  50. /// <summary>Notifies the client of the session_id sent in the ServerHello.</summary>
  51. /// <param name="sessionID"/>
  52. /// <seealso cref="TlsContext.Session"/>
  53. void NotifySessionID(byte[] sessionID);
  54. void NotifySelectedCipherSuite(int selectedCipherSuite);
  55. /// <exception cref="IOException"/>
  56. void NotifySelectedPsk(TlsPsk selectedPsk);
  57. /// <summary>The protocol implementation validates that any server extensions received correspond to client
  58. /// extensions sent.</summary>
  59. /// <remarks>
  60. /// If further processing of the server extensions is needed, it can be done in this callback. NOTE: This is
  61. /// not called for session resumption handshakes.
  62. /// </remarks>
  63. /// <param name="serverExtensions">(Int32 -> byte[])</param>
  64. /// <exception cref="IOException"/>
  65. void ProcessServerExtensions(IDictionary serverExtensions);
  66. /// <param name="serverSupplementalData">(SupplementalDataEntry)</param>
  67. /// <exception cref="IOException"/>
  68. void ProcessServerSupplementalData(IList serverSupplementalData);
  69. /// <exception cref="IOException"/>
  70. TlsPskIdentity GetPskIdentity();
  71. /// <exception cref="IOException"/>
  72. TlsSrpIdentity GetSrpIdentity();
  73. /// <exception cref="IOException"/>
  74. TlsDHGroupVerifier GetDHGroupVerifier();
  75. /// <exception cref="IOException"/>
  76. TlsSrpConfigVerifier GetSrpConfigVerifier();
  77. /// <exception cref="IOException"/>
  78. TlsAuthentication GetAuthentication();
  79. /// <returns>(SupplementalDataEntry)</returns>
  80. /// <exception cref="IOException"/>
  81. IList GetClientSupplementalData();
  82. /// <summary>RFC 5077 3.3. NewSessionTicket Handshake Message</summary>
  83. /// <remarks>
  84. /// This method will be called (only) when a NewSessionTicket handshake message is received. The ticket is
  85. /// opaque to the client and clients MUST NOT examine the ticket under the assumption that it complies with e.g.
  86. /// RFC 5077 4. "Recommended Ticket Construction".
  87. /// </remarks>
  88. /// <param name="newSessionTicket">The ticket.</param>
  89. /// <exception cref="IOException"/>
  90. void NotifyNewSessionTicket(NewSessionTicket newSessionTicket);
  91. }
  92. }
  93. #pragma warning restore
  94. #endif