Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsIArray; |
michael@0 | 10 | interface nsIX509CertValidity; |
michael@0 | 11 | interface nsIASN1Object; |
michael@0 | 12 | |
michael@0 | 13 | /** |
michael@0 | 14 | * This represents a X.509 certificate. |
michael@0 | 15 | */ |
michael@0 | 16 | [scriptable, uuid(6286dd8c-c1a1-11e3-941d-180373d97f24)] |
michael@0 | 17 | interface nsIX509Cert : nsISupports { |
michael@0 | 18 | |
michael@0 | 19 | /** |
michael@0 | 20 | * A nickname for the certificate. |
michael@0 | 21 | */ |
michael@0 | 22 | readonly attribute AString nickname; |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * The primary email address of the certificate, if present. |
michael@0 | 26 | */ |
michael@0 | 27 | readonly attribute AString emailAddress; |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * Obtain a list of all email addresses |
michael@0 | 31 | * contained in the certificate. |
michael@0 | 32 | * |
michael@0 | 33 | * @param length The number of strings in the returned array. |
michael@0 | 34 | * @return An array of email addresses. |
michael@0 | 35 | */ |
michael@0 | 36 | void getEmailAddresses(out unsigned long length, |
michael@0 | 37 | [retval, array, size_is(length)] out wstring addresses); |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Check whether a given address is contained in the certificate. |
michael@0 | 41 | * The comparison will convert the email address to lowercase. |
michael@0 | 42 | * The behaviour for non ASCII characters is undefined. |
michael@0 | 43 | * |
michael@0 | 44 | * @param aEmailAddress The address to search for. |
michael@0 | 45 | * |
michael@0 | 46 | * @return True if the address is contained in the certificate. |
michael@0 | 47 | */ |
michael@0 | 48 | boolean containsEmailAddress(in AString aEmailAddress); |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * The subject owning the certificate. |
michael@0 | 52 | */ |
michael@0 | 53 | readonly attribute AString subjectName; |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * The subject's common name. |
michael@0 | 57 | */ |
michael@0 | 58 | readonly attribute AString commonName; |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * The subject's organization. |
michael@0 | 62 | */ |
michael@0 | 63 | readonly attribute AString organization; |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * The subject's organizational unit. |
michael@0 | 67 | */ |
michael@0 | 68 | readonly attribute AString organizationalUnit; |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * The fingerprint of the certificate's public key, |
michael@0 | 72 | * calculated using the SHA1 algorithm. |
michael@0 | 73 | */ |
michael@0 | 74 | readonly attribute AString sha1Fingerprint; |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * The fingerprint of the certificate's public key, |
michael@0 | 78 | * calculated using the MD5 algorithm. |
michael@0 | 79 | */ |
michael@0 | 80 | readonly attribute AString md5Fingerprint; |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * A human readable name identifying the hardware or |
michael@0 | 84 | * software token the certificate is stored on. |
michael@0 | 85 | */ |
michael@0 | 86 | readonly attribute AString tokenName; |
michael@0 | 87 | |
michael@0 | 88 | /** |
michael@0 | 89 | * The subject identifying the issuer certificate. |
michael@0 | 90 | */ |
michael@0 | 91 | readonly attribute AString issuerName; |
michael@0 | 92 | |
michael@0 | 93 | /** |
michael@0 | 94 | * The serial number the issuer assigned to this certificate. |
michael@0 | 95 | */ |
michael@0 | 96 | readonly attribute AString serialNumber; |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * The issuer subject's common name. |
michael@0 | 100 | */ |
michael@0 | 101 | readonly attribute AString issuerCommonName; |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | * The issuer subject's organization. |
michael@0 | 105 | */ |
michael@0 | 106 | readonly attribute AString issuerOrganization; |
michael@0 | 107 | |
michael@0 | 108 | /** |
michael@0 | 109 | * The issuer subject's organizational unit. |
michael@0 | 110 | */ |
michael@0 | 111 | readonly attribute AString issuerOrganizationUnit; |
michael@0 | 112 | |
michael@0 | 113 | /** |
michael@0 | 114 | * The certificate used by the issuer to sign this certificate. |
michael@0 | 115 | */ |
michael@0 | 116 | readonly attribute nsIX509Cert issuer; |
michael@0 | 117 | |
michael@0 | 118 | /** |
michael@0 | 119 | * This certificate's validity period. |
michael@0 | 120 | */ |
michael@0 | 121 | readonly attribute nsIX509CertValidity validity; |
michael@0 | 122 | |
michael@0 | 123 | /** |
michael@0 | 124 | * A unique identifier of this certificate within the local storage. |
michael@0 | 125 | */ |
michael@0 | 126 | readonly attribute string dbKey; |
michael@0 | 127 | |
michael@0 | 128 | /** |
michael@0 | 129 | * A human readable identifier to label this certificate. |
michael@0 | 130 | */ |
michael@0 | 131 | readonly attribute string windowTitle; |
michael@0 | 132 | |
michael@0 | 133 | /** |
michael@0 | 134 | * Constants to classify the type of a certificate. |
michael@0 | 135 | */ |
michael@0 | 136 | const unsigned long UNKNOWN_CERT = 0; |
michael@0 | 137 | const unsigned long CA_CERT = 1 << 0; |
michael@0 | 138 | const unsigned long USER_CERT = 1 << 1; |
michael@0 | 139 | const unsigned long EMAIL_CERT = 1 << 2; |
michael@0 | 140 | const unsigned long SERVER_CERT = 1 << 3; |
michael@0 | 141 | |
michael@0 | 142 | /** |
michael@0 | 143 | * Constants for certificate verification results. |
michael@0 | 144 | */ |
michael@0 | 145 | const unsigned long VERIFIED_OK = 0; |
michael@0 | 146 | const unsigned long NOT_VERIFIED_UNKNOWN = 1 << 0; |
michael@0 | 147 | const unsigned long CERT_REVOKED = 1 << 1; |
michael@0 | 148 | const unsigned long CERT_EXPIRED = 1 << 2; |
michael@0 | 149 | const unsigned long CERT_NOT_TRUSTED = 1 << 3; |
michael@0 | 150 | const unsigned long ISSUER_NOT_TRUSTED = 1 << 4; |
michael@0 | 151 | const unsigned long ISSUER_UNKNOWN = 1 << 5; |
michael@0 | 152 | const unsigned long INVALID_CA = 1 << 6; |
michael@0 | 153 | const unsigned long USAGE_NOT_ALLOWED = 1 << 7; |
michael@0 | 154 | const unsigned long SIGNATURE_ALGORITHM_DISABLED = 1 << 8; |
michael@0 | 155 | |
michael@0 | 156 | /** |
michael@0 | 157 | * Constants that describe the certified usages of a certificate. |
michael@0 | 158 | * |
michael@0 | 159 | * Deprecated and unused |
michael@0 | 160 | */ |
michael@0 | 161 | const unsigned long CERT_USAGE_SSLClient = 0; |
michael@0 | 162 | const unsigned long CERT_USAGE_SSLServer = 1; |
michael@0 | 163 | const unsigned long CERT_USAGE_SSLServerWithStepUp = 2; |
michael@0 | 164 | const unsigned long CERT_USAGE_SSLCA = 3; |
michael@0 | 165 | const unsigned long CERT_USAGE_EmailSigner = 4; |
michael@0 | 166 | const unsigned long CERT_USAGE_EmailRecipient = 5; |
michael@0 | 167 | const unsigned long CERT_USAGE_ObjectSigner = 6; |
michael@0 | 168 | const unsigned long CERT_USAGE_UserCertImport = 7; |
michael@0 | 169 | const unsigned long CERT_USAGE_VerifyCA = 8; |
michael@0 | 170 | const unsigned long CERT_USAGE_ProtectedObjectSigner = 9; |
michael@0 | 171 | const unsigned long CERT_USAGE_StatusResponder = 10; |
michael@0 | 172 | const unsigned long CERT_USAGE_AnyCA = 11; |
michael@0 | 173 | |
michael@0 | 174 | /** |
michael@0 | 175 | * Obtain a list of certificates that contains this certificate |
michael@0 | 176 | * and the issuing certificates of all involved issuers, |
michael@0 | 177 | * up to the root issuer. |
michael@0 | 178 | * |
michael@0 | 179 | * @return The chain of certifficates including the issuers. |
michael@0 | 180 | */ |
michael@0 | 181 | nsIArray getChain(); |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * Obtain an array of human readable strings describing |
michael@0 | 185 | * the certificate's certified usages. |
michael@0 | 186 | * |
michael@0 | 187 | * @param localOnly Do not hit the network, even if revocation information |
michael@0 | 188 | * downloading is currently activated. |
michael@0 | 189 | * @param verified The certificate verification result, see constants. |
michael@0 | 190 | * @param count The number of human readable usages returned. |
michael@0 | 191 | * @param usages The array of human readable usages. |
michael@0 | 192 | */ |
michael@0 | 193 | void getUsagesArray(in boolean localOnly, |
michael@0 | 194 | out uint32_t verified, |
michael@0 | 195 | out uint32_t count, |
michael@0 | 196 | [array, size_is(count)] out wstring usages); |
michael@0 | 197 | |
michael@0 | 198 | /** |
michael@0 | 199 | * Obtain a single comma separated human readable string describing |
michael@0 | 200 | * the certificate's certified usages. |
michael@0 | 201 | * |
michael@0 | 202 | * @param localOnly Do not hit the network, even if revocation information |
michael@0 | 203 | * downloading is currently activated. |
michael@0 | 204 | * @param verified The certificate verification result, see constants. |
michael@0 | 205 | * @param purposes The string listing the usages. |
michael@0 | 206 | */ |
michael@0 | 207 | void getUsagesString(in boolean localOnly, out uint32_t verified, out AString usages); |
michael@0 | 208 | |
michael@0 | 209 | /** |
michael@0 | 210 | * This is the attribute which describes the ASN1 layout |
michael@0 | 211 | * of the certificate. This can be used when doing a |
michael@0 | 212 | * "pretty print" of the certificate's ASN1 structure. |
michael@0 | 213 | */ |
michael@0 | 214 | readonly attribute nsIASN1Object ASN1Structure; |
michael@0 | 215 | |
michael@0 | 216 | /** |
michael@0 | 217 | * Obtain a raw binary encoding of this certificate |
michael@0 | 218 | * in DER format. |
michael@0 | 219 | * |
michael@0 | 220 | * @param length The number of bytes in the binary encoding. |
michael@0 | 221 | * @param data The bytes representing the DER encoded certificate. |
michael@0 | 222 | */ |
michael@0 | 223 | void getRawDER(out unsigned long length, |
michael@0 | 224 | [retval, array, size_is(length)] out octet data); |
michael@0 | 225 | |
michael@0 | 226 | /** |
michael@0 | 227 | * Test whether two certificate instances represent the |
michael@0 | 228 | * same certificate. |
michael@0 | 229 | * |
michael@0 | 230 | * @return Whether the certificates are equal |
michael@0 | 231 | */ |
michael@0 | 232 | boolean equals(in nsIX509Cert other); |
michael@0 | 233 | |
michael@0 | 234 | /** |
michael@0 | 235 | * The base64 encoding of the DER encoded public key info using the specified |
michael@0 | 236 | * digest. |
michael@0 | 237 | */ |
michael@0 | 238 | readonly attribute ACString sha256SubjectPublicKeyInfoDigest; |
michael@0 | 239 | }; |