nsITLSServerSocket.idl 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsIServerSocket.idl"
  5. interface nsIX509Cert;
  6. interface nsITLSServerSecurityObserver;
  7. interface nsISocketTransport;
  8. [scriptable, uuid(cc2c30f9-cfaa-4b8a-bd44-c24881981b74)]
  9. interface nsITLSServerSocket : nsIServerSocket
  10. {
  11. /**
  12. * serverCert
  13. *
  14. * The server's certificate that is presented to the client during the TLS
  15. * handshake. This is required to be set before calling |asyncListen|.
  16. */
  17. attribute nsIX509Cert serverCert;
  18. /**
  19. * setSessionTickets
  20. *
  21. * Whether the server should support session tickets. Defaults to true. This
  22. * should be set before calling |asyncListen| if you wish to change the
  23. * default.
  24. */
  25. void setSessionTickets(in boolean aSessionTickets);
  26. /**
  27. * Values for setRequestClientCertificate
  28. */
  29. // Never request
  30. const unsigned long REQUEST_NEVER = 0;
  31. // Request (but do not require) during the first handshake only
  32. const unsigned long REQUEST_FIRST_HANDSHAKE = 1;
  33. // Request (but do not require) during each handshake
  34. const unsigned long REQUEST_ALWAYS = 2;
  35. // Require during the first handshake only
  36. const unsigned long REQUIRE_FIRST_HANDSHAKE = 3;
  37. // Require during each handshake
  38. const unsigned long REQUIRE_ALWAYS = 4;
  39. /**
  40. * setRequestClientCertificate
  41. *
  42. * Whether the server should request and/or require a client auth certificate
  43. * from the client. Defaults to REQUEST_NEVER. See the possible options
  44. * above. This should be set before calling |asyncListen| if you wish to
  45. * change the default.
  46. */
  47. void setRequestClientCertificate(in unsigned long aRequestClientCert);
  48. /**
  49. * setCipherSuites
  50. *
  51. * The server's cipher suites that is used by the TLS handshake.
  52. * This is required to be set before calling |asyncListen|.
  53. */
  54. void setCipherSuites([array, size_is(aLength)] in unsigned short aCipherSuites,
  55. in unsigned long aLength);
  56. /**
  57. * setVersionRange
  58. *
  59. * The server's TLS versions that is used by the TLS handshake.
  60. * This is required to be set before calling |asyncListen|.
  61. *
  62. * aMinVersion and aMaxVersion is a TLS version value from
  63. * |nsITLSClientStatus| constants.
  64. */
  65. void setVersionRange(in unsigned short aMinVersion,
  66. in unsigned short aMaxVersion);
  67. };
  68. /**
  69. * Security summary for a given TLS client connection being handled by a
  70. * |nsITLSServerSocket| server.
  71. *
  72. * This is accessible through the security info object on the transport, which
  73. * will be an instance of |nsITLSServerConnectionInfo| (see below).
  74. *
  75. * The values of these attributes are available once the |onHandshakeDone|
  76. * method of the security observer has been called (see
  77. * |nsITLSServerSecurityObserver| below).
  78. */
  79. [scriptable, uuid(205e273d-2439-449b-bfc5-fc555c87dbc4)]
  80. interface nsITLSClientStatus : nsISupports
  81. {
  82. /**
  83. * peerCert
  84. *
  85. * The client's certificate, if one was requested via |requestCertificate|
  86. * above and supplied by the client.
  87. */
  88. readonly attribute nsIX509Cert peerCert;
  89. /**
  90. * Values for tlsVersionUsed, as defined by TLS
  91. */
  92. const short SSL_VERSION_3 = 0x0300;
  93. const short TLS_VERSION_1 = 0x0301;
  94. const short TLS_VERSION_1_1 = 0x0302;
  95. const short TLS_VERSION_1_2 = 0x0303;
  96. const short TLS_VERSION_1_3 = 0x0304;
  97. const short TLS_VERSION_UNKNOWN = -1;
  98. /**
  99. * tlsVersionUsed
  100. *
  101. * The version of TLS used by the connection. See values above.
  102. */
  103. readonly attribute short tlsVersionUsed;
  104. /**
  105. * cipherName
  106. *
  107. * Name of the symetric cipher used, such as
  108. * "AES-GCM" or "CAMELLIA".
  109. */
  110. readonly attribute ACString cipherName;
  111. /**
  112. * cipherSuite
  113. *
  114. * Name of the cipher suite used, such as
  115. * "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256".
  116. * See security/nss/lib/ssl/sslinfo.c for the possible values.
  117. */
  118. readonly attribute ACString cipherSuite;
  119. /**
  120. * keyLength
  121. *
  122. * The "effective" key size of the symmetric key in bits.
  123. */
  124. readonly attribute unsigned long keyLength;
  125. /**
  126. * macLength
  127. *
  128. * The size of the MAC in bits.
  129. */
  130. readonly attribute unsigned long macLength;
  131. };
  132. /**
  133. * Connection info for a given TLS client connection being handled by a
  134. * |nsITLSServerSocket| server. This object is thread-safe.
  135. *
  136. * This is exposed as the security info object on the transport, so it can be
  137. * accessed via |transport.securityInfo|.
  138. *
  139. * This interface is available by the time the |onSocketAttached| is called,
  140. * which is the first time the TLS server consumer is notified of a new client.
  141. */
  142. [scriptable, uuid(8a93f5d5-eddd-4c62-a4bd-bfd297653184)]
  143. interface nsITLSServerConnectionInfo : nsISupports
  144. {
  145. /**
  146. * setSecurityObserver
  147. *
  148. * Set the security observer to be notified when the TLS handshake has
  149. * completed.
  150. */
  151. void setSecurityObserver(in nsITLSServerSecurityObserver observer);
  152. /**
  153. * serverSocket
  154. *
  155. * The nsITLSServerSocket instance that accepted this client connection.
  156. */
  157. readonly attribute nsITLSServerSocket serverSocket;
  158. /**
  159. * status
  160. *
  161. * Security summary for this TLS client connection. Note that the values of
  162. * this interface are not available until the TLS handshake has completed.
  163. * See |nsITLSClientStatus| above for more details.
  164. */
  165. readonly attribute nsITLSClientStatus status;
  166. };
  167. [scriptable, uuid(1f62e1ae-e546-4a38-8917-d428472ed736)]
  168. interface nsITLSServerSecurityObserver : nsISupports
  169. {
  170. /**
  171. * onHandsakeDone
  172. *
  173. * This method is called once the TLS handshake is completed. This takes
  174. * place after |onSocketAccepted| has been called, which typically opens the
  175. * streams to keep things moving along. It's important to be aware that the
  176. * handshake has not completed at the point that |onSocketAccepted| is called,
  177. * so no security verification can be done until this method is called.
  178. */
  179. void onHandshakeDone(in nsITLSServerSocket aServer,
  180. in nsITLSClientStatus aStatus);
  181. };