|
|
Certificate Functions
Table of Contents | Previous
| Next
| Index
This chapter describes the functions and related types used to work with a certificate database such as the cert7.db database provided with Communicator.
Validating Certificates Manipulating Certificates Getting Certificate Information Comparing SecItem Objects
CERT_VerifyCertNow
CERT_VerifyCertName
CERT_CheckCertValidTimes
NSS_CmpCertChainWCANames
Checks that the current date is within the certificate's validity period and that the CA signature on the certificate is valid.
#include <cert.h> SECStatus CERT_VerifyCertNow( CERTCertDBHandle *handle, CERTCertificate *cert, PRBool checkSig, SECCertUsage certUsage, void *wincx);
This function has the following parameters:
The function returns one of these values:
The CERT_VerifyCertNow function must call one or more PK11 functions to obtain the services of a PKCS #11 module. Some of the PK11 functions require a PIN argument (see SSL_SetPKCS11PinArg for details), which must be specified in the wincx parameter. To obtain the value to pass in the wincx parameter, call SSL_RevealPinArg.
Compares the common name specified in the subject DN for a certificate with a specified hostname.
#include <cert.h> SECStatus CERT_VerifyCertName( CERTCertificate *cert, char *hostname);
This function has the following parameters:
The function returns one of these values:
The comparison performed by CERT_VerifyCertName is not a simple string comparison. Instead, it takes account of the following rules governing the construction of common names in SSL server certificates:
Checks whether a specified time is within a certificate's validity period.
#include <cert.h> #include <certt.h> SECCertTimeValidity CERT_CheckCertValidTimes( CERTCertificate *cert, int64 t);
This function has the following parameters:
The function returns an enumerator of type SECCertTimeValidity:
typedef enum { secCertTimeValid, secCertTimeExpired, secCertTimeNotValidYet } SECCertTimeValidity;
Determines whether any of the signers in the certificate chain for a specified certificate are on a specified list of CA names.
#include <nss.h> SECStatus NSS_CmpCertChainWCANames( CERTCertificate *cert, CERTDistNames *caNames);
This function has the following parameters:
The function returns one of these values:
CERT_DupCertificate
CERT_DestroyCertificate
Makes a shallow copy of a specified certificate.
#include <cert.h> CERTCertificate *CERT_DupCertificate(CERTCertificate *c)
This function has the following parameter:
If successful, the function returns a pointer to a certificate object of type CERTCertificate.
The CERT_DupCertificate function increments the reference count for the certificate passed in the c parameter.
Destroys a certificate object.
#include <cert.h> #include <certt.h> void CERT_DestroyCertificate(CERTCertificate *cert);
This function has the following parameter:
Certificate and key structures are shared objects. When an application makes a copy of a particular certificate or key structure that already exists in memory, SSL makes a shallow copy--that is, it increments the reference count for that object rather than making a whole new copy. When you call CERT_DestroyCertificate or SECKEY_DestroyPrivateKey, the function decrements the reference count and, if the reference count reaches zero as a result, both frees the memory and sets all the bits to zero. The use of the word "destroy" in function names or in the description of a function implies reference counting.
Never alter the contents of a certificate or key structure. If you attempt to do so, the change affects all the shallow copies of that structure and can cause severe problems.
CERT_FindCertByName
CERT_GetCertNicknames
CERT_FreeNicknames
CERT_GetDefaultCertDB
NSS_FindCertKEAType
Finds the certificate in the certificate database with a specified DN.
#include <cert.h> CERTCertificate *CERT_FindCertByName ( CERTCertDBHandle *handle, SECItem *name);
This function has the following parameters:
If successful, the function returns a certificate object of type CERTCertificate.
Returns the nicknames of the certificates in a specified certificate database.
#include <cert.h> #include <certt.h> CERTCertNicknames *CERT_GetCertNicknames ( CERTCertDBHandle *handle, int what, void *wincx);
This function has the following parameters:
The function returns a CERTCertNicknames object containing the requested nicknames.
CERT_GetCertNicknames must call one or more PK11 functions to obtain the services of a PKCS #11 module. Some of the PK11 functions require a PIN argument (see SSL_SetPKCS11PinArg for details), which must be specified in the wincx parameter. To obtain the value to pass in the wincx parameter, call SSL_RevealPinArg.
Frees a CERTCertNicknames structure. This structure is returned by CERT_GetCertNicknames.
#include <cert.h> void CERT_FreeNicknames(CERTCertNicknames *nicknames);
This function has the following parameter:
Returns a handle to the default certificate database.
#include <cert.h> CERTCertDBHandle *CERT_GetDefaultCertDB(void);
The function returns the CERTCertDBHandle for the default certificate database.
This function is useful for determining whether the default certificate database has been opened.
Returns key exchange type of the keys in an SSL server certificate.
#include <nss.h> SSLKEAType NSS_FindCertKEAType(CERTCertificate * cert);
This function has the following parameter:
The function returns one of these values:
Compares two SECItem objects and returns a SECComparison enumerator that shows the difference between them.
#include <secitem.h> #include <seccomon.h> SECComparison SECITEM_CompareItem( SECItem *a, SECItem *b);
This function has the following parameters:
The function returns an enumerator of type SECComparison.
typedef enum _SECComparison { SECLessThan = -1, SECEqual = 0, SECGreaterThan = 1 } SECComparison;
Table of Contents | Previous
| Next
| Index
Last Updated: 01/17/00 16:36:41
|