Crypt::NSS::Certificate - X.509 certificate and related fuctions


Crypt-NSS documentation Contained in the Crypt-NSS distribution.

Index


Code Index:

NAME

Top

Crypt::NSS::Certificate - X.509 certificate and related fuctions

INTERFACE

Top

CLASS METHODS

from_base64_DER ( $data : string ) : Crypt::NSS::Certificate

Creates a new certificate from a Base64 encoded DER string.

INSTANCE METHODS

Getting information about the certificate

issuer ( ) : string
get_issuer ( ) : string
issuer_name ( ) : string

Returns the DN of the issuer of the certificate.

subject ( ) : string
get_subject ( ) : string
subject_name ( ) : string

Returns the certificates DN.

email_address ( ) : string
get_email_address ( ) : string

Returns the email address of the certificate if any.

public_key ( ) : Crypt::NSS::PublicKey
get_public_key ( ) : Crypt::NSS::PublicKey

Returns the certificates public key.

Verifying the certificate

verify_hostname ( $pattern : string ) : boolean

Verifies that the hostname in the certificate matches the given hostname pattern.

get_validity_for_datetime( $year : integer, $month : integer, $day : integer [, $hour : integer, $minute : integer, $second : integer, $usec : integer ]) : integer

Checks if the certificate is valid for the given date and optional time. Returns -1 if the certificate has expired, 0 if it's still valid or 1 if it's not valid yet but will be in the future.

is_valid_now ( ) : boolean

Checks if the certificate is valid now (localtime).

Miscellaneous methods

clone ( ) : Crypt::NSS::Certificate

Returns a copy of the certificate.


Crypt-NSS documentation Contained in the Crypt-NSS distribution.

package Crypt::NSS::Certificate;

use strict;
use warnings;

# Method aliases
*get_issuer = \&issuer;
*issuer_name = \&issuer;
*get_subject = \&subject;
*subject_name = \&subject;
*get_email_address = \&email_address;
*get_public_key = \&public_key;

sub is_valid_now {
    my $self = shift;
    my ($sec, $min, $hour, $mday, $month, $year) = (localtime(time))[0..5];
    return $self->get_validity_for_datetime($year + 1900, $month, $mday, $hour, $min, $sec) == 0;
}


1;
__END__