nsIX509Cert.idl 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * ***** BEGIN LICENSE BLOCK *****
  4. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. *
  6. * The contents of this file are subject to the Mozilla Public License Version
  7. * 1.1 (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. * http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is mozilla.org code.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications Corporation.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. * Javier Delgadillo <[email protected]>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. #include "nsISupports.idl"
  40. interface nsIArray;
  41. interface nsIX509CertValidity;
  42. interface nsIASN1Object;
  43. /**
  44. * This represents a X.509 certificate.
  45. *
  46. * @status FROZEN
  47. */
  48. [scriptable, uuid(f0980f60-ee3d-11d4-998b-00b0d02354a0)]
  49. interface nsIX509Cert : nsISupports {
  50. /**
  51. * A nickname for the certificate.
  52. */
  53. readonly attribute AString nickname;
  54. /**
  55. * The primary email address of the certificate, if present.
  56. */
  57. readonly attribute AString emailAddress;
  58. /**
  59. * Obtain a list of all email addresses
  60. * contained in the certificate.
  61. *
  62. * @param length The number of strings in the returned array.
  63. * @return An array of email addresses.
  64. */
  65. void getEmailAddresses(out unsigned long length,
  66. [retval, array, size_is(length)] out wstring addresses);
  67. /**
  68. * Check whether a given address is contained in the certificate.
  69. * The comparison will convert the email address to lowercase.
  70. * The behaviour for non ASCII characters is undefined.
  71. *
  72. * @param aEmailAddress The address to search for.
  73. *
  74. * @return True if the address is contained in the certificate.
  75. */
  76. boolean containsEmailAddress(in AString aEmailAddress);
  77. /**
  78. * The subject owning the certificate.
  79. */
  80. readonly attribute AString subjectName;
  81. /**
  82. * The subject's common name.
  83. */
  84. readonly attribute AString commonName;
  85. /**
  86. * The subject's organization.
  87. */
  88. readonly attribute AString organization;
  89. /**
  90. * The subject's organizational unit.
  91. */
  92. readonly attribute AString organizationalUnit;
  93. /**
  94. * The fingerprint of the certificate's public key,
  95. * calculated using the SHA1 algorithm.
  96. */
  97. readonly attribute AString sha1Fingerprint;
  98. /**
  99. * The fingerprint of the certificate's public key,
  100. * calculated using the MD5 algorithm.
  101. */
  102. readonly attribute AString md5Fingerprint;
  103. /**
  104. * A human readable name identifying the hardware or
  105. * software token the certificate is stored on.
  106. */
  107. readonly attribute AString tokenName;
  108. /**
  109. * The subject identifying the issuer certificate.
  110. */
  111. readonly attribute AString issuerName;
  112. /**
  113. * The serial number the issuer assigned to this certificate.
  114. */
  115. readonly attribute AString serialNumber;
  116. /**
  117. * The issuer subject's common name.
  118. */
  119. readonly attribute AString issuerCommonName;
  120. /**
  121. * The issuer subject's organization.
  122. */
  123. readonly attribute AString issuerOrganization;
  124. /**
  125. * The issuer subject's organizational unit.
  126. */
  127. readonly attribute AString issuerOrganizationUnit;
  128. /**
  129. * The certificate used by the issuer to sign this certificate.
  130. */
  131. readonly attribute nsIX509Cert issuer;
  132. /**
  133. * This certificate's validity period.
  134. */
  135. readonly attribute nsIX509CertValidity validity;
  136. /**
  137. * A unique identifier of this certificate within the local storage.
  138. */
  139. readonly attribute string dbKey;
  140. /**
  141. * A human readable identifier to label this certificate.
  142. */
  143. readonly attribute string windowTitle;
  144. /**
  145. * Constants to classify the type of a certificate.
  146. */
  147. const unsigned long UNKNOWN_CERT = 0;
  148. const unsigned long CA_CERT = 1 << 0;
  149. const unsigned long USER_CERT = 1 << 1;
  150. const unsigned long EMAIL_CERT = 1 << 2;
  151. const unsigned long SERVER_CERT = 1 << 3;
  152. /**
  153. * Constants for certificate verification results.
  154. */
  155. const unsigned long VERIFIED_OK = 0;
  156. const unsigned long NOT_VERIFIED_UNKNOWN = 1 << 0;
  157. const unsigned long CERT_REVOKED = 1 << 1;
  158. const unsigned long CERT_EXPIRED = 1 << 2;
  159. const unsigned long CERT_NOT_TRUSTED = 1 << 3;
  160. const unsigned long ISSUER_NOT_TRUSTED = 1 << 4;
  161. const unsigned long ISSUER_UNKNOWN = 1 << 5;
  162. const unsigned long INVALID_CA = 1 << 6;
  163. const unsigned long USAGE_NOT_ALLOWED = 1 << 7;
  164. /**
  165. * Constants that describe the certified usages of a certificate.
  166. */
  167. const unsigned long CERT_USAGE_SSLClient = 0;
  168. const unsigned long CERT_USAGE_SSLServer = 1;
  169. const unsigned long CERT_USAGE_SSLServerWithStepUp = 2;
  170. const unsigned long CERT_USAGE_SSLCA = 3;
  171. const unsigned long CERT_USAGE_EmailSigner = 4;
  172. const unsigned long CERT_USAGE_EmailRecipient = 5;
  173. const unsigned long CERT_USAGE_ObjectSigner = 6;
  174. const unsigned long CERT_USAGE_UserCertImport = 7;
  175. const unsigned long CERT_USAGE_VerifyCA = 8;
  176. const unsigned long CERT_USAGE_ProtectedObjectSigner = 9;
  177. const unsigned long CERT_USAGE_StatusResponder = 10;
  178. const unsigned long CERT_USAGE_AnyCA = 11;
  179. /**
  180. * Obtain a list of certificates that contains this certificate
  181. * and the issuing certificates of all involved issuers,
  182. * up to the root issuer.
  183. *
  184. * @return The chain of certifficates including the issuers.
  185. */
  186. nsIArray getChain();
  187. /**
  188. * Obtain an array of human readable strings describing
  189. * the certificate's certified usages.
  190. *
  191. * @param ignoreOcsp Do not use OCSP even if it is currently activated.
  192. * @param verified The certificate verification result, see constants.
  193. * @param count The number of human readable usages returned.
  194. * @param usages The array of human readable usages.
  195. */
  196. void getUsagesArray(in boolean ignoreOcsp,
  197. out PRUint32 verified,
  198. out PRUint32 count,
  199. [array, size_is(count)] out wstring usages);
  200. /**
  201. * Obtain a single comma separated human readable string describing
  202. * the certificate's certified usages.
  203. *
  204. * @param ignoreOcsp Do not use OCSP even if it is currently activated.
  205. * @param verified The certificate verification result, see constants.
  206. * @param purposes The string listing the usages.
  207. */
  208. void getUsagesString(in boolean ignoreOcsp, out PRUint32 verified, out AString usages);
  209. /**
  210. * Verify the certificate for a particular usage.
  211. *
  212. * @return The certificate verification result, see constants.
  213. */
  214. unsigned long verifyForUsage(in unsigned long usage);
  215. /**
  216. * This is the attribute which describes the ASN1 layout
  217. * of the certificate. This can be used when doing a
  218. * "pretty print" of the certificate's ASN1 structure.
  219. */
  220. readonly attribute nsIASN1Object ASN1Structure;
  221. /**
  222. * Obtain a raw binary encoding of this certificate
  223. * in DER format.
  224. *
  225. * @param length The number of bytes in the binary encoding.
  226. * @param data The bytes representing the DER encoded certificate.
  227. */
  228. void getRawDER(out unsigned long length,
  229. [retval, array, size_is(length)] out octet data);
  230. /**
  231. * Test whether two certificate instances represent the
  232. * same certificate.
  233. *
  234. * @return Whether the certificates are equal
  235. */
  236. boolean equals(in nsIX509Cert other);
  237. };