nsICertOverrideService.idl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. interface nsIArray;
  8. interface nsIX509Cert;
  9. %{C++
  10. #define NS_CERTOVERRIDE_CONTRACTID "@mozilla.org/security/certoverride;1"
  11. %}
  12. /**
  13. * This represents the global list of triples
  14. * {host:port, cert-fingerprint, allowed-overrides}
  15. * that the user wants to accept without further warnings.
  16. */
  17. [scriptable, uuid(be019e47-22fc-4355-9f16-9ab047d6742d)]
  18. interface nsICertOverrideService : nsISupports {
  19. /**
  20. * Override Untrusted
  21. */
  22. const short ERROR_UNTRUSTED = 1;
  23. /**
  24. * Override hostname Mismatch
  25. */
  26. const short ERROR_MISMATCH = 2;
  27. /**
  28. * Override Time error
  29. */
  30. const short ERROR_TIME = 4;
  31. /**
  32. * The given cert should always be accepted for the given hostname:port,
  33. * regardless of errors verifying the cert.
  34. * Host:Port is a primary key, only one entry per host:port can exist.
  35. * The implementation will store a fingerprint of the cert.
  36. * The implementation will decide which fingerprint alg is used.
  37. *
  38. * Each override is specific to exactly the errors overridden, so
  39. * overriding everything won't match certs at the given host:port
  40. * which only exhibit some subset of errors.
  41. *
  42. * @param aHostName The host (punycode) this mapping belongs to
  43. * @param aPort The port this mapping belongs to, if it is -1 then it
  44. * is internaly treated as 443
  45. * @param aCert The cert that should always be accepted
  46. * @param aOverrideBits The precise set of errors we want to be overriden
  47. */
  48. void rememberValidityOverride(in ACString aHostName,
  49. in int32_t aPort,
  50. in nsIX509Cert aCert,
  51. in uint32_t aOverrideBits,
  52. in boolean aTemporary);
  53. /**
  54. * Certs with the given fingerprint should always be accepted for the
  55. * given hostname:port, regardless of errors verifying the cert.
  56. * Host:Port is a primary key, only one entry per host:port can exist.
  57. * The fingerprint should be an SHA-256 hash of the certificate.
  58. *
  59. * @param aHostName The host (punycode) this mapping belongs to
  60. * @param aPort The port this mapping belongs to, if it is -1 then it
  61. * is internaly treated as 443
  62. * @param aCertFingerprint The cert fingerprint that should be accepted, in
  63. * the format 'AA:BB:...' (colon-separated upper-case hex bytes).
  64. * @param aOverrideBits The errors we want to be overriden
  65. */
  66. void rememberTemporaryValidityOverrideUsingFingerprint(
  67. in ACString aHostName,
  68. in int32_t aPort,
  69. in ACString aCertFingerprint,
  70. in uint32_t aOverrideBits);
  71. /**
  72. * Return whether this host, port, cert triple has a stored override.
  73. * If so, the outparams will contain the specific errors that were
  74. * overridden, and whether the override is permanent, or only for the current
  75. * session.
  76. *
  77. * @param aHostName The host (punycode) this mapping belongs to
  78. * @param aPort The port this mapping belongs to, if it is -1 then it
  79. * is internally treated as 443
  80. * @param aCert The certificate this mapping belongs to
  81. * @param aOverrideBits The errors that are currently overridden
  82. * @param aIsTemporary Whether the stored override is session-only,
  83. * or permanent
  84. * @return Whether an override has been stored for this host+port+cert
  85. */
  86. boolean hasMatchingOverride(in ACString aHostName,
  87. in int32_t aPort,
  88. in nsIX509Cert aCert,
  89. out uint32_t aOverrideBits,
  90. out boolean aIsTemporary);
  91. /**
  92. * Retrieve the stored override for the given hostname:port.
  93. *
  94. * @param aHostName The host (punycode) whose entry should be tested
  95. * @param aPort The port whose entry should be tested, if it is -1 then it
  96. * is internaly treated as 443
  97. * @param aHashAlg On return value True, the fingerprint hash algorithm
  98. * as an OID value in dotted notation.
  99. * @param aFingerprint On return value True, the stored fingerprint
  100. * @param aOverrideBits The errors that are currently overriden
  101. * @return whether a matching override entry for aHostNameWithPort
  102. * and aFingerprint is currently on file
  103. */
  104. boolean getValidityOverride(in ACString aHostName,
  105. in int32_t aPort,
  106. out ACString aHashAlg,
  107. out ACString aFingerprint,
  108. out uint32_t aOverrideBits,
  109. out boolean aIsTemporary);
  110. /**
  111. * Remove a override for the given hostname:port.
  112. *
  113. * @param aHostName The host (punycode) whose entry should be cleared.
  114. * @param aPort The port whose entry should be cleared.
  115. * If it is -1, then it is internaly treated as 443.
  116. * If it is 0 and aHostName is "all:temporary-certificates",
  117. * then all temporary certificates should be cleared.
  118. */
  119. void clearValidityOverride(in ACString aHostName,
  120. in int32_t aPort);
  121. /**
  122. * Is the given cert used in rules?
  123. *
  124. * @param aCert The cert we're looking for
  125. * @return how many override entries are currently on file
  126. * for the given certificate
  127. */
  128. uint32_t isCertUsedForOverrides(in nsIX509Cert aCert,
  129. in boolean aCheckTemporaries,
  130. in boolean aCheckPermanents);
  131. };