nsISiteSecurityService.idl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 "nsISupports.idl"
  5. interface nsIURI;
  6. interface nsIObserver;
  7. interface nsIHttpChannel;
  8. interface nsISSLStatus;
  9. %{C++
  10. #include "nsTArrayForwardDeclare.h"
  11. class nsCString;
  12. namespace mozilla
  13. {
  14. namespace pkix
  15. {
  16. class Time;
  17. }
  18. }
  19. %}
  20. [ref] native nsCStringTArrayRef(nsTArray<nsCString>);
  21. [ref] native mozillaPkixTime(mozilla::pkix::Time);
  22. [scriptable, uuid(91ea3803-9c79-45d9-97bf-88bc80269236)]
  23. interface nsISiteSecurityService : nsISupports
  24. {
  25. const uint32_t HEADER_HSTS = 0;
  26. const uint32_t HEADER_HPKP = 1; /* no longer used */
  27. const uint32_t HEADER_OMS = 2;
  28. const uint32_t Success = 0;
  29. const uint32_t ERROR_UNKNOWN = 1;
  30. const uint32_t ERROR_UNTRUSTWORTHY_CONNECTION = 2;
  31. const uint32_t ERROR_COULD_NOT_PARSE_HEADER = 3;
  32. const uint32_t ERROR_NO_MAX_AGE = 4;
  33. const uint32_t ERROR_MULTIPLE_MAX_AGES = 5;
  34. const uint32_t ERROR_INVALID_MAX_AGE = 6;
  35. const uint32_t ERROR_MULTIPLE_INCLUDE_SUBDOMAINS = 7;
  36. const uint32_t ERROR_INVALID_INCLUDE_SUBDOMAINS = 8;
  37. const uint32_t ERROR_INVALID_PIN = 9; /* no longer used */
  38. const uint32_t ERROR_MULTIPLE_REPORT_URIS = 10; /* no longer used */
  39. const uint32_t ERROR_PINSET_DOES_NOT_MATCH_CHAIN = 11; /* no longer used */
  40. const uint32_t ERROR_NO_BACKUP_PIN = 12; /* no longer used */
  41. const uint32_t ERROR_COULD_NOT_SAVE_STATE = 13;
  42. const uint32_t ERROR_ROOT_NOT_BUILT_IN = 14;
  43. /**
  44. * Parses a given HTTP header and records the results internally.
  45. * Currently two header types are supported: HSTS (aka STS) and HPKP
  46. * The format of the HSTS header is defined by the HSTS specification:
  47. * https://tools.ietf.org/html/rfc6797
  48. * and allows a host to specify that future HTTP requests should be
  49. * upgraded to HTTPS.
  50. * The format of the HPKP header is defined by the HPKP specification:
  51. * https://tools.ietf.org/html/rfc7469
  52. * and allows a host to specify a subset of trusted anchors to be used
  53. * in future HTTPS connections.
  54. *
  55. * @param aType the type of security header in question.
  56. * @param aSourceURI the URI of the resource with the HTTP header.
  57. * @param aSSLStatus the SSLStatus of the current channel
  58. * @param aHeader the HTTP response header specifying security data.
  59. * @param aFlags options for this request as defined in nsISocketProvider:
  60. * NO_PERMANENT_STORAGE
  61. * @param aMaxAge the parsed max-age directive of the header.
  62. * @param aIncludeSubdomains the parsed includeSubdomains directive.
  63. * @param aFailureResult a more specific failure result if NS_ERROR_FAILURE
  64. was returned.
  65. * @return NS_OK if it succeeds
  66. * NS_ERROR_FAILURE if it can't be parsed
  67. * NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA
  68. * if there are unrecognized tokens in the header.
  69. */
  70. void processHeader(in uint32_t aType,
  71. in nsIURI aSourceURI,
  72. in string aHeader,
  73. in nsISSLStatus aSSLStatus,
  74. in uint32_t aFlags,
  75. [optional] out unsigned long long aMaxAge,
  76. [optional] out boolean aIncludeSubdomains,
  77. [optional] out uint32_t aFailureResult);
  78. /**
  79. * Same as processHeader but without checking for the security properties
  80. * of the connection. Use ONLY for testing.
  81. */
  82. void unsafeProcessHeader(in uint32_t aType,
  83. in nsIURI aSourceURI,
  84. in string aHeader,
  85. in uint32_t aFlags,
  86. [optional] out unsigned long long aMaxAge,
  87. [optional] out boolean aIncludeSubdomains,
  88. [optional] out uint32_t aFailureResult);
  89. /**
  90. * Given a header type, removes state relating to that header of a host,
  91. * including the includeSubdomains state that would affect subdomains.
  92. * This essentially removes the state for the domain tree rooted at this
  93. * host. If any preloaded information is present for that host, that
  94. * information will then be used instead of any other previously existing
  95. * state, unless the force parameter is set.
  96. *
  97. * @param aType the type of security state in question
  98. * @param aURI the URI of the target host
  99. * @param aFlags options for this request as defined in nsISocketProvider:
  100. * NO_PERMANENT_STORAGE
  101. */
  102. void removeState(in uint32_t aType,
  103. in nsIURI aURI,
  104. in uint32_t aFlags);
  105. /**
  106. * See isSecureURI
  107. *
  108. * @param aType the type of security state in question.
  109. * @param aHost the hostname (punycode) to query for state.
  110. * @param aFlags options for this request as defined in nsISocketProvider:
  111. * NO_PERMANENT_STORAGE
  112. * @param aCached true if we have cached information regarding whether or not
  113. * the host is HSTS, false otherwise.
  114. */
  115. boolean isSecureHost(in uint32_t aType,
  116. in string aHost,
  117. in uint32_t aFlags,
  118. [optional] out boolean aCached);
  119. /**
  120. * Checks whether or not the URI's hostname has a given security state set.
  121. * For example, for HSTS:
  122. * The URI is an HSTS URI if either the host has the HSTS state set, or one
  123. * of its super-domains has the HSTS "includeSubdomains" flag set.
  124. * NOTE: this function makes decisions based only on the
  125. * host contained in the URI, and disregards other portions of the URI
  126. * such as path and port.
  127. *
  128. * @param aType the type of security state in question.
  129. * @param aURI the URI to query for STS state.
  130. * @param aFlags options for this request as defined in nsISocketProvider:
  131. * NO_PERMANENT_STORAGE
  132. * @param aCached true if we have cached information regarding whether or not
  133. * the host is HSTS, false otherwise.
  134. */
  135. boolean isSecureURI(in uint32_t aType, in nsIURI aURI, in uint32_t aFlags,
  136. [optional] out boolean aCached);
  137. /**
  138. * Removes all non-preloaded security state by resetting to factory-original
  139. * settings.
  140. */
  141. void clearAll();
  142. };
  143. %{C++
  144. #define NS_SSSERVICE_CONTRACTID "@mozilla.org/ssservice;1"
  145. %}