.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "X509 3pm" .TH X509 3pm "2013-12-01" "perl v5.20.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Crypt::OpenSSL::X509 \- Perl extension to OpenSSL's X509 API. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Crypt::OpenSSL::X509; \& \& my $x509 = Crypt::OpenSSL::X509\->new_from_file(\*(Aqcert.pem\*(Aq); \& \& print $x509\->pubkey() . "\en"; \& print $x509\->subject() . "\en"; \& print $x509\->issuer() . "\en"; \& print $x509\->email() . "\en"; \& print $x509\->hash() . "\en"; \& print $x509\->notBefore() . "\en"; \& print $x509\->notAfter() . "\en"; \& print $x509\->modulus() . "\en"; \& print $x509\->exponent() . "\en"; \& print $x509\->fingerprint_sha1() . "\en"; \& print $x509\->fingerprint_md5() . "\en"; \& print $x509\->as_string() . "\en"; \& \& my $x509 = Crypt::OpenSSL::X509\->new_from_string( \& $der_encoded_data, Crypt::OpenSSL::X509::FORMAT_ASN1 \& ); \& \& # given a time offset of $seconds, will the certificate be valid? \& if ($x509\->checkend($seconds)) { \& # cert is expired at $seconds offset \& } else { \& # cert is ok at $seconds offset \& } \& \& my $exts = $x509\->extensions_by_oid(); \& \& foreach my $oid (keys %$exts) { \& my $ext = $$exts{$oid}; \& print $oid, " ", $ext\->object()\->name(), ": ", $ext\->value(), "\en"; \& } .Ve .SH "ABSTRACT" .IX Header "ABSTRACT" .Vb 1 \& Crypt::OpenSSL::X509 \- Perl extension to OpenSSL\*(Aqs X509 API. .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" .Vb 1 \& This implement a large majority of OpenSSL\*(Aqs useful X509 API. \& \& The email() method supports both certificates where the \& subject is of the form: \& "... CN=Firstname lastname/emailAddress=user@domain", and also \& certificates where there is a X509v3 Extension of the form \& "X509v3 Subject Alternative Name: email=user@domain". .Ve .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" None by default. .PP On request: .PP .Vb 2 \& FORMAT_UNDEF FORMAT_ASN1 FORMAT_TEXT FORMAT_PEM FORMAT_NETSCAPE \& FORMAT_PKCS12 FORMAT_SMIME FORMAT_ENGINE FORMAT_IISSGC .Ve .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "X509 \s-1CONSTRUCTORS\s0" .IX Subsection "X509 CONSTRUCTORS" .IP "new ( )" 4 .IX Item "new ( )" Create a new X509 object. .IP "new_from_string ( \s-1STRING\s0 [ \s-1FORMAT \s0] )" 4 .IX Item "new_from_string ( STRING [ FORMAT ] )" .PD 0 .IP "new_from_file ( \s-1FILENAME\s0 [ \s-1FORMAT \s0] )" 4 .IX Item "new_from_file ( FILENAME [ FORMAT ] )" .PD Create a new X509 object from a string or file. \f(CW\*(C`FORMAT\*(C'\fR should be \f(CW\*(C`FORMAT_ASN1\*(C'\fR or \f(CW\*(C`FORMAT_PEM\*(C'\fR. .SS "X509 \s-1ACCESSORS\s0" .IX Subsection "X509 ACCESSORS" .IP "subject" 4 .IX Item "subject" Subject name as a string. .IP "issuer" 4 .IX Item "issuer" Issuer name as a string. .IP "serial" 4 .IX Item "serial" Serial number as a string. .IP "hash" 4 .IX Item "hash" Subject name hash as a string. .IP "notBefore" 4 .IX Item "notBefore" \&\f(CW\*(C`notBefore\*(C'\fR time as a string. .IP "notAfter" 4 .IX Item "notAfter" \&\f(CW\*(C`notAfter\*(C'\fR time as a string. .IP "email" 4 .IX Item "email" Email address as a string. .IP "version" 4 .IX Item "version" Certificate version as a string. .IP "sig_alg_name" 4 .IX Item "sig_alg_name" Signature algorithm name as a string. .IP "key_alg_name" 4 .IX Item "key_alg_name" Public key algorithm name as a string. .IP "curve" 4 .IX Item "curve" Name of the \s-1EC\s0 curve used in the public key. .SS "X509 \s-1METHODS\s0" .IX Subsection "X509 METHODS" .IP "subject_name ( )" 4 .IX Item "subject_name ( )" .PD 0 .IP "issuer_name ( )" 4 .IX Item "issuer_name ( )" .PD Return a Name object for the subject or issuer name. Methods for handling Name objects are given below. .IP "is_selfsigned ( )" 4 .IX Item "is_selfsigned ( )" Return Boolean value if subject and issuer name are the same. .IP "as_string ( [ \s-1FORMAT \s0] )" 4 .IX Item "as_string ( [ FORMAT ] )" Return the certificate as a string in the specified format. \f(CW\*(C`FORMAT\*(C'\fR can be one of \f(CW\*(C`FORMAT_PEM\*(C'\fR (the default), \f(CW\*(C`FORMAT_ASN1\*(C'\fR, or \f(CW\*(C`FORMAT_NETSCAPE\*(C'\fR. .IP "modulus ( )" 4 .IX Item "modulus ( )" Return the modulus for an \s-1RSA\s0 public key as a string of hex digits. For \s-1DSA\s0 and \s-1EC\s0 return the public key. Other algorithms are not supported. .IP "bit_length ( )" 4 .IX Item "bit_length ( )" Return the length of the modulus as a number of bits. .IP "fingerprint_md5 ( )" 4 .IX Item "fingerprint_md5 ( )" .PD 0 .IP "fingerprint_sha1 ( )" 4 .IX Item "fingerprint_sha1 ( )" .PD Return the specified message digest for the certificate. .IP "checkend( \s-1OFFSET \s0)" 4 .IX Item "checkend( OFFSET )" Given an offset in seconds, will the certificate be expired? Returns True if the certificate will be expired. False otherwise. .IP "pubkey ( )" 4 .IX Item "pubkey ( )" Return the \s-1RSA, DSA,\s0 or \s-1EC\s0 public key. .IP "num_extensions ( )" 4 .IX Item "num_extensions ( )" Return the number of extensions in the certificate. .IP "extension ( \s-1INDEX \s0)" 4 .IX Item "extension ( INDEX )" Return the Extension specified by the integer \f(CW\*(C`INDEX\*(C'\fR. Methods for handling Extension objects are given below. .IP "extensions_by_oid ( )" 4 .IX Item "extensions_by_oid ( )" .PD 0 .IP "extensions_by_name ( )" 4 .IX Item "extensions_by_name ( )" .IP "extensions_by_long_name ( )" 4 .IX Item "extensions_by_long_name ( )" .PD Return a hash of Extensions indexed by \s-1OID\s0 or name. .IP "has_extension_oid ( \s-1OID \s0)" 4 .IX Item "has_extension_oid ( OID )" Return true if the certificate has the extension specified by \f(CW\*(C`OID\*(C'\fR. .SS "X509::Extension \s-1METHODS\s0" .IX Subsection "X509::Extension METHODS" .IP "critical ( )" 4 .IX Item "critical ( )" Return a value indicating if the extension is critical or not. \&\s-1FIXME:\s0 the value is an \s-1ASN.1 BOOLEAN\s0 value. .IP "object ( )" 4 .IX Item "object ( )" Return the ObjectID of the extension. Methods for handling ObjectID objects are given below. .IP "value ( )" 4 .IX Item "value ( )" Return the value or data of the extension. \&\s-1FIXME:\s0 the value is returned as a string but may represent a complex object. .SS "X509::ObjectID \s-1METHODS\s0" .IX Subsection "X509::ObjectID METHODS" .IP "name ( )" 4 .IX Item "name ( )" Return the long name of the object as a string. .IP "oid ( )" 4 .IX Item "oid ( )" Return the numeric dot-separated form of the object identifier as a string. .SS "X509::Name \s-1METHODS\s0" .IX Subsection "X509::Name METHODS" .IP "as_string ( )" 4 .IX Item "as_string ( )" Return a string representation of the Name .IP "entries ( )" 4 .IX Item "entries ( )" Return an array of Name_Entry objects. Methods for handling Name_Entry objects are given below. .IP "has_entry ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "has_entry ( TYPE [ LASTPOS ] )" .PD 0 .IP "has_long_entry ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "has_long_entry ( TYPE [ LASTPOS ] )" .IP "has_oid_entry ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "has_oid_entry ( TYPE [ LASTPOS ] )" .PD Return true if a name has an entry of the specified \f(CW\*(C`TYPE\*(C'\fR. Depending on the function the \f(CW\*(C`TYPE\*(C'\fR may be in the short form (e.g. \f(CW\*(C`CN\*(C'\fR), long form (\f(CW\*(C`commonName\*(C'\fR) or \s-1OID \s0(\f(CW2.5.4.3\fR). If \f(CW\*(C`LASTPOS\*(C'\fR is specified then the search is made from that index rather than from the start. .IP "get_index_by_type ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "get_index_by_type ( TYPE [ LASTPOS ] )" .PD 0 .IP "get_index_by_long_type ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "get_index_by_long_type ( TYPE [ LASTPOS ] )" .IP "get_index_by_oid_type ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "get_index_by_oid_type ( TYPE [ LASTPOS ] )" .PD Return the index of an entry of the specified \f(CW\*(C`TYPE\*(C'\fR in a name. Depending on the function the \f(CW\*(C`TYPE\*(C'\fR may be in the short form (e.g. \f(CW\*(C`CN\*(C'\fR), long form (\f(CW\*(C`commonName\*(C'\fR) or \s-1OID \s0(\f(CW2.5.4.3\fR). If \f(CW\*(C`LASTPOS\*(C'\fR is specified then the search is made from that index rather than from the start. .IP "get_entry_by_type ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "get_entry_by_type ( TYPE [ LASTPOS ] )" .PD 0 .IP "get_entry_by_long_type ( \s-1TYPE\s0 [ \s-1LASTPOS \s0] )" 4 .IX Item "get_entry_by_long_type ( TYPE [ LASTPOS ] )" .PD These methods work similarly to get_index_by_* but return the Name_Entry rather than the index. .SS "X509::Name_Entry \s-1METHODS\s0" .IX Subsection "X509::Name_Entry METHODS" .IP "as_string ( [ \s-1LONG \s0] )" 4 .IX Item "as_string ( [ LONG ] )" Return a string representation of the Name_Entry of the form \f(CW\*(C`typeName=Value\*(C'\fR. If \f(CW\*(C`LONG\*(C'\fR is 1, the long form of the type is used. .IP "type ( [ \s-1LONG \s0] )" 4 .IX Item "type ( [ LONG ] )" Return a string representation of the type of the Name_Entry. If \f(CW\*(C`LONG\*(C'\fR is 1, the long form of the type is used. .IP "value ( )" 4 .IX Item "value ( )" Return a string representation of the value of the Name_Entry. .IP "is_printableString ( )" 4 .IX Item "is_printableString ( )" .PD 0 .IP "is_ia5string ( )" 4 .IX Item "is_ia5string ( )" .IP "is_utf8string ( )" 4 .IX Item "is_utf8string ( )" .IP "is_asn1_type ( [\s-1ASN1_TYPE\s0] )" 4 .IX Item "is_asn1_type ( [ASN1_TYPE] )" .PD Return true if the Name_Entry value is of the specified type. The value of \f(CW\*(C`ASN1_TYPE\*(C'\fR should be as listed in OpenSSL's \f(CW\*(C`asn1.h\*(C'\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIOpenSSL\fR\|(1), Crypt::OpenSSL::RSA, Crypt::OpenSSL::Bignum .SH "AUTHOR" .IX Header "AUTHOR" Dan Sully .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" David O'Callaghan, Daniel Kahn Gillmor .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2004\-2013 by Dan Sully .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.