summaryrefslogtreecommitdiff
path: root/doc/rst/legacy/cert_findcertbyissuerandsn/index.rst
blob: 933fff206c8d7d120f80795086d1bb247dbbdd80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
.. _mozilla_projects_nss_cert_findcertbyissuerandsn:

CERT_FindCertByIssuerAndSN
==========================

.. container::

   Find a certificate in the database with the given issuer and serial number.

`Syntax <#syntax>`__
~~~~~~~~~~~~~~~~~~~~

.. container::

   .. code::

      #include <cert.h>
      CERTCertificate *CERT_FindCertByIssuerAndSN (

          CERTCertDBHandle *handle,
          CERTIssuerAndSN *issuerAndSN            );

`Parameters <#parameters>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   +-----------------+-------------------------------------------------------------------------------+
   | ``handle``      | *in* pointer to a `CERTCertDBHandle </en-US/NSS/CERTCertDBHandle>`__          |
   |                 | representing the certificate database to look in                              |
   +-----------------+-------------------------------------------------------------------------------+
   | ``issuerAndSN`` | *in* pointer to a `CERTIssuerAndSN </en-US/NSS/CERTIssuerAndSN>`__ that must  |
   |                 | be properly formed to contain the issuer name and the serial number (see      |
   |                 | [Example])                                                                    |
   +-----------------+-------------------------------------------------------------------------------+

`Description <#description>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   This function creates a certificate key using the ``issuerAndSN`` and it then uses the key to
   find the matching certificate in the database.

`Returns <#returns>`__
~~~~~~~~~~~~~~~~~~~~~~

.. container::

   A pointer to a `CERTCertificate </en-US/NSS/CERTCertificate>`__ representing the certificate in
   the database that matched the issuer and serial number, or ``NULL`` if none was found. The
   certificate is a shallow copy, use
   `CERT_DestroyCertificate </en-US/NSS/CERT_DestroyCertificate>`__ to decrement the reference count
   on the certificate instance.

`Example <#example>`__
~~~~~~~~~~~~~~~~~~~~~~

.. container::

   .. code::

      CERTIssuerAndSN issuerSN;
      issuerSN.derIssuer.data = caName->data;
      issuerSN.derIssuer.len = caName->len;
      issuerSN.serialNumber.data = authorityKeyID->authCertSerialNumber.data;
      issuerSN.serialNumber.len = authorityKeyID->authCertSerialNumber.len;
      issuerCert = CERT_FindCertByIssuerAndSN(cert->dbhandle, &issuerSN);
      if ( issuerCert == NULL ) {
          PORT_SetError (SEC_ERROR_UNKNOWN_ISSUER);
      }

.. _see_also:

`See Also <#see_also>`__
~~~~~~~~~~~~~~~~~~~~~~~~

.. container::

   Occurrences of
   ```CERT_FindCertByIssuerAndSN`` <http://lxr.mozilla.org/security/ident?i=CERT_FindCertByIssuerAndSN>`__
   in the current NSS source code (generated by `LXR <http://lxr.mozilla.org/security/>`__).