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
5#include "nsISupports.idl"
6
7interface nsIX509Cert;
8interface nsILocalCertGetCallback;
9interface nsILocalCertCallback;
10
11[scriptable, uuid(9702fdd4-4c2c-439c-ba2e-19cda018eb99)]
12interface nsILocalCertService : nsISupports
13{
14  /**
15   * Get or create a new self-signed X.509 cert to represent this device over a
16   * secure transport, like TLS.
17   *
18   * The cert is stored permanently in the profile's key store after first use,
19   * and is valid for 1 year.  If an expired or otherwise invalid cert is found
20   * with the nickname supplied here, it is removed and a new one is made.
21   *
22   * @param nickname Nickname that identifies the cert
23   * @param cb       Callback to be notified with the result
24   */
25  [must_use]
26  void getOrCreateCert(in ACString nickname, in nsILocalCertGetCallback cb);
27
28  /**
29   * Remove a X.509 cert with the given nickname.
30   *
31   * @param nickname Nickname that identifies the cert
32   * @param cb       Callback to be notified with the result
33   */
34  [must_use]
35  void removeCert(in ACString nickname, in nsILocalCertCallback cb);
36
37  /**
38   * Whether calling |getOrCreateCert| or |removeCert| will trigger a login
39   * prompt to be displayed.  Generally this happens if the user has set a
40   * master password, but has not yet logged in.
41   */
42  [must_use]
43  readonly attribute boolean loginPromptRequired;
44};
45
46[scriptable, uuid(cc09633e-7c70-4093-a9cf-79ab676ca8a9)]
47interface nsILocalCertGetCallback : nsISupports
48{
49  /**
50   * Called with the result of the getOrCreateCert operation above.
51   *
52   * @param cert   Requested cert, or null if some error
53   * @param result Result code from the get operation
54   */
55  void handleCert(in nsIX509Cert cert, in nsresult result);
56};
57
58[scriptable, uuid(518124e9-55e6-4e23-97c0-4995b3a1bec6)]
59interface nsILocalCertCallback : nsISupports
60{
61  /**
62   * Called with the result of the removeCert operation above.
63   *
64   * @param result Result code from the operation
65   */
66  void handleResult(in nsresult result);
67};
68
69%{ C++
70#define LOCALCERTSERVICE_CONTRACTID \
71  "@mozilla.org/security/local-cert-service;1"
72%}
73