CkCert Java Programming Reference Documentation
CkCert
* This is a freeware class/component/library.
Digital certificate component / class
Properties
// str is a CkString object (output) get_CspName( str )
If the HasKeyContainer property is true, then the certificate is linked to a key container and this property contains the name of the associated CSP (cryptographic service provider). When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// Returns a boolean value get_Expired( )
Has a value of true if the certificate or any certificate in the chain of authority has expired. This information is not available when running on Windows 95/98 computers.
// Returns a boolean value get_ForClientAuthentication( )
true if this certificate can be used for client authentication, otherwise false.
// Returns a boolean value get_ForCodeSigning( )
true if this certificate can be used for code signing, otherwise false.
// Returns a boolean value get_ForSecureEmail( )
true if this certificate can be used for sending secure email, otherwise false.
// Returns a boolean value get_ForServerAuthentication( )
true if this certificate can be used for server authentication, otherwise false.
// Returns a boolean value get_ForTimeStamping( )
true if this certificate can be used for time stamping, otherwise false.
// Returns a boolean value get_HasKeyContainer( )
Indicates whether this certificate is linked to a key container. If true then the certificate is linked to a key container (usually containing a private key). If false, then it is not.
When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// Returns an integer value get_IntendedKeyUsage( )
Bitflags indicating the intended usages of the certificate.
The flags are:
Digital Signature: 0x80
Non-Repudiation: 0x40
Key Encipherment: 0x20
Data Encipherment: 0x10
Key Agreement: 0x08
Certificate Signing: 0x04
CRL Signing: 0x02
Encipher-Only: 0x01
// Returns a boolean value get_IsRoot( )
true if this is the root certificate, otherwise false.
// str is a CkString object (output) get_IssuerC( str )
The certificate issuer's country.
// str is a CkString object (output) get_IssuerCN( str )
The certificate issuer's common name.
// str is a CkString object (output) get_IssuerDN( str )
The issuer's full distinguished name.
// str is a CkString object (output) get_IssuerE( str )
The certificate issuer's email address.
// str is a CkString object (output) get_IssuerL( str )
The certificate issuer's locality, which could be a city, count, township, or other geographic region.
// str is a CkString object (output) get_IssuerO( str )
The certificate issuer's organization, which is typically the company name.
// str is a CkString object (output) get_IssuerOU( str )
The certificate issuer's organizational unit, which is the unit within the organization.
// str is a CkString object (output) get_IssuerS( str )
The certificate issuer's state or province.
// str is a CkString object (output) get_KeyContainerName( str )
If the HasKeyContainer property is true, then the certificate is linked to a key container and this property contains the name of the key container.
When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// str is a CkString object (output) LastErrorHtml( str )
Error information in HTML format for the last method called.
// str is a CkString object (output) LastErrorText( str )
Error information in plain-text format for the last method called.
// str is a CkString object (output) LastErrorXml( str )
Error information in XML format for the last method called.
// Returns a boolean value get_MachineKeyset( )
If the HasKeyContainer property is true, then the certificate is linked to a key container and this property indicates whether the key container is in the machine's keyset or in the keyset specific to the logged on user's account. If true, the key container is within the machine keyset. If false, it's in the user's keyset.
When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// Returns a boolean value get_Revoked( )
true if the certificate or any certificate in the chain of authority has been revoked. This information is not available when running on Windows 95/98 computers.
Note: If this property is false, it could mean that it was not able to check the revocation status. Because of this uncertainty, a CheckRevoked method has been added. It returns an integer indicating one of three possible states: 1 (revoked) , 0 (not revoked), -1 (unable to check revocation status).
// str is a CkString object (output) get_Rfc822Name( str )
The RFC-822 name of the certificate.
// str is a CkString object (output) get_SerialNumber( str )
The certificate's serial number.
// Returns a boolean value get_SignatureVerified( )
True if the certificate and all certificates in the chain of authority have valid signatures. This information is not available when running on Windows 95/98 computers.
// Returns a boolean value get_Silent( )
If the HasKeyContainer property is true, then the certificate is linked to a key container and this property indicates whether accessing the private key will cause the operating system to launch an interactive warning dialog. If false a warning dialog will be displayed. If true then private key accesses are silent.
When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// str is a CkString object (output) get_SubjectC( str )
The certificate subject's country.
// str is a CkString object (output) get_SubjectCN( str )
The certificate subject's common name.
// str is a CkString object (output) get_SubjectDN( str )
The certificate subject's full distinguished name.
// str is a CkString object (output) get_SubjectE( str )
The certificate subject's email address.
// str is a CkString object (output) get_SubjectL( str )
The certificate subject's locality, which could be a city, count, township, or other geographic region.
// str is a CkString object (output) get_SubjectO( str )
The certificate subject's organization, which is typically the company name.
// str is a CkString object (output) get_SubjectOU( str )
The certificate subject's organizational unit, which is the unit within the organization.
// str is a CkString object (output) get_SubjectS( str )
The certificate subject's state or province.
// Returns a boolean value get_TrustedRoot( )
True if the certificate has a trusted root authority. This information is not available when running on Windows 95/98 computers.
// sysTime is a SYSTEMTIME object (output) get_ValidFrom( sysTime )
The date this certificate becomes (or became) valid.
// sysTime is a SYSTEMTIME object (output) get_ValidTo( sysTime )
The date this certificate becomes (or became) invalid.
// str is a CkString object (output) get_Version( str )
The version of this component, such as "1.0"
Methods
// Returns an integer value CheckRevoked( )
Returns 1 if the certificate has been revoked, 0 if not revoked, and -1 if unable to check the revocation status.
// data is a CkByteData object (output) // Returns a boolean value ExportCertDer( data )
Exports the digital certificate to ASN.1 DER format.
// filename is a string (input) // Returns a boolean value ExportCertDerFile( filename )
Exports the digital certificate to ASN.1 DER format binary file. Returns true for success, false for failure.
// str is a CkString object (output) // Returns a boolean value ExportCertPem( str )
Exports the digital certificate to an unencrypted PEM formatted string. Returns true for success, false for failure.
// filename is a string (input) // Returns a boolean value ExportCertPemFile( filename )
Exports the digital certificate to an unencrypted PEM formatted file. Returns true for success, false for failure.
ExportPrivateKey( )
Exports the certificate's private key.
ExportPublicKey( )
Exports the certificate's public key.
// pfxFilename is a string (input) // password is a string (input) // bIncludeChain is a boolean (input) // Returns a boolean value ExportToPfxFile( pfxFilename, password, bIncludeChain )
To be documented soon...
// str is a CkString object (output) // Returns a boolean value GetEncoded( str )
Returns an encoded string representation of the certificate, which can be passed to SetFromEncoded to recreate the certificate object. Returns true for success, false for failure.
// Returns a boolean value HasPrivateKey( )
Returns true if the private key is installed on the local system for the certificate. This information is not available when running on Windows 95/98 computers.
// keyContainerName is a string (input) // bMachineKeyset is a boolean (input) // bForSigning is a boolean (input) // Returns a boolean value LinkPrivateKey( keyContainerName, bMachineKeyset, bForSigning )
Associates a private key with a certificate. The private key is specified by providing the name of the key container where it can be found. The 2nd argument indicates whether the key container is from the machine-wide keyset (true), or from the keyset specific to the logged-on user (false). Private keys can be imported into a key container by calling the KeyContainer's ImportPrivateKey method. Once a certificate has been linked, the private key is available for creating digital signatures or decrypting. Note: Certificates imported from a PFX or from a Certificate Authority will already be "linked" and it is not necessary to call this method. Returns true for success, false for failure.
// cn is a string (input) // Returns a boolean value LoadByCommonName( cn )
Searches the Windows Local Machine and Current User registry-based certificate stores for a certificate having the common name specified. If found, the certificate is loaded and ready for use. Returns true for success, false for failure. Select Cert for Encrypted Email
// emailAddress is a string (input) // Returns a boolean value LoadByEmailAddress( emailAddress )
Searches the Windows Local Machine and Current User registry-based certificate stores for a certificate containing the email address specified. If found, the certificate is loaded and ready for use. Returns true for success, false for failure. Select Cert for Encrypted Email
// encodedCert is a string (input) // Returns a boolean value LoadFromBase64( encodedCert )
Loads an ASN.1 or DER encoded certificate represented in a Base64 string.
// filename is a string (input) // Returns a boolean value LoadFromFile( filename )
Loads a certificate from a .cer, .p7b, or .pem file. This method accepts certificates from files in any of the following formats: 1. DER encoded binary X.509 (.CER) 2. Base-64 encoded X.509 (.CER) 3. Cryptographic Message Syntax Standard - PKCS #7 Certificates (.P7B) 4. PEM format This method decodes the certificate based on the contents if finds within the file, and not based on the file extension. If your certificate is in a file having a different extension, try loading it using this method before assuming it won't work. This method does not load .p12 or .pfx (PKCS #12) files.
// pfxData is a CkByteData object (output) // password is a string (input) // Returns a boolean value LoadPfxData( pfxData, password )
To be documented soon...
// buf is a byte array (input) // bufLen is an integer (input) // password is a string (input) // Returns a boolean value LoadPfxData2( buf, bufLen, password )
To be documented soon...
// filename is a string (input) // password is a string (input) // Returns a boolean value LoadPfxFile( filename, password )
To be documented soon...
// inFilename is a string (input) // outFilename is a string (input) // Returns a boolean value PemFileToDerFile( inFilename, outFilename )
Converts a PEM file to a DER file. Returns true for success, false for failure.
// filename is a string (input) // Returns a boolean value SaveLastError( filename )
Saves the last error information to an XML formatted file.
// filename is a string (input) // Returns a boolean value SaveToFile( filename )
Saves a certificate object to a .cer file. Returns true for success, false for failure.
// encodedCert is a string (input) // Returns a boolean value SetFromEncoded( encodedCert )
Initializes the certificate object from an encoded string created by the GetEncoded method.
// Returns a string cspName( )
If the HasKeyContainer property is true, then the certificate is linked to a key container and this property contains the name of the associated CSP (cryptographic service provider). When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// Returns a string exportCertPem( )
Exports the digital certificate to an unencrypted PEM formatted string.
// Returns a string getEncoded( )
Returns an encoded string representation of the certificate, which can be passed to SetFromEncoded to recreate the certificate object.
// Returns a string issuerC( )
The certificate issuer's country.
// Returns a string issuerCN( )
The certificate issuer's common name.
// Returns a string issuerDN( )
The issuer's full distinguished name.
// Returns a string issuerE( )
The certificate issuer's email address.
// Returns a string issuerL( )
The certificate issuer's locality, which could be a city, count, township, or other geographic region.
// Returns a string issuerO( )
The certificate issuer's organization, which is typically the company name.
// Returns a string issuerOU( )
The certificate issuer's organizational unit, which is the unit within the organization.
// Returns a string issuerS( )
The certificate issuer's state or province.
// Returns a string keyContainerName( )
If the HasKeyContainer property is true, then the certificate is linked to a key container and this property contains the name of the key container.
When a certificate is linked to a key container , the following properties will provide information about the key container and private key: CspName, KeyContainerName, MachineKeyset, and Silent.
// Returns a string lastErrorHtml( )
Error information in HTML format for the last method called.
// Returns a string lastErrorText( )
Error information in plain-text format for the last method called.
// Returns a string lastErrorXml( )
Error information in XML format for the last method called.
// Returns a string rfc822Name( )
The RFC-822 name of the certificate.
// Returns a string serialNumber( )
The certificate's serial number.
// Returns a string sha1Thumbprint( )
Hexidecimal string of the SHA-1 thumbprint for the certificate.
// Returns a string subjectC( )
The certificate subject's country.
// Returns a string subjectCN( )
The certificate subject's common name.
// Returns a string subjectDN( )
The certificate subject's full distinguished name.
// Returns a string subjectE( )
The certificate subject's email address.
// Returns a string subjectL( )
The certificate subject's locality, which could be a city, count, township, or other geographic region.
// Returns a string subjectO( )
The certificate subject's organization, which is typically the company name.
// Returns a string subjectOU( )
The certificate subject's organizational unit, which is the unit within the organization.
// Returns a string subjectS( )
The certificate subject's state or province.
// Returns a string version( )
The version of this component, such as "1.0"
|