.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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 >0, 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 .\" ======================================================================== .\" .IX Title "X509 3pm" .TH X509 3pm "2022-10-19" "perl v5.36.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\->hash() . "\en"; \& print $x509\->email() . "\en"; \& print $x509\->issuer() . "\en"; \& print $x509\->issuer_hash() . "\en"; \& print $x509\->notBefore() . "\en"; \& print $x509\->notAfter() . "\en"; \& print $x509\->modulus() . "\en"; \& print $x509\->exponent() . "\en"; \& print $x509\->fingerprint_md5() . "\en"; \& print $x509\->fingerprint_sha256() . "\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_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 "issuer_hash" 4 .IX Item "issuer_hash" Issuer name hash as a string. .IP "serial" 4 .IX Item "serial" Serial number as a string. .IP "hash" 4 .IX Item "hash" Alias for subject_hash .IP "subject_hash" 4 .IX Item "subject_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 addresses as string, if multiple addresses found, they are separated by a space (' '). .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) or \f(CW\*(C`FORMAT_ASN1\*(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 ( )" .IP "fingerprint_sha224 ( )" 4 .IX Item "fingerprint_sha224 ( )" .IP "fingerprint_sha256 ( )" 4 .IX Item "fingerprint_sha256 ( )" .IP "fingerprint_sha384 ( )" 4 .IX Item "fingerprint_sha384 ( )" .IP "fingerprint_sha512 ( )" 4 .IX Item "fingerprint_sha512 ( )" .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 of the extension as an \fBasn1parse\fR\|(1) style hex dump. .IP "as_string ( )" 4 .IX Item "as_string ( )" Return a human-readable version of the extension as formatted by X509V3_EXT_print. Note that this will return an empty string for OIDs with unknown \s-1ASN.1\s0 encodings. .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 "ISSUE REPORTING" .IX Header "ISSUE REPORTING" Please report any bugs or feature requests using \fBGitHub\fR. .IP "\(bu" 4 GitHub Issues .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 OpenSSL website .IP "\(bu" 4 Crypt::OpenSSL::RSA .IP "\(bu" 4 Crypt::OpenSSL::Bignum .IP "\(bu" 4 Crypt::OpenSSL::Guess .SH "AUTHOR" .IX Header "AUTHOR" .IP "\(bu" 4 Dan Sully, original author .IP "\(bu" 4 Jonas Brømsø, current maintainer .IP "\(bu" 4 Please see the \*(L"\s-1ACKNOWLEDGEMENTS\*(R"\s0 section for a list of contributors. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" In alphabetical order. .IP "\(bu" 4 \&\f(CW@eserte\fR .IP "\(bu" 4 \&\f(CW@kmx\fR .IP "\(bu" 4 \&\f(CW@stphnlyd\fR .IP "\(bu" 4 Ashley Hindmarsh \f(CW@bestscarper\fR .IP "\(bu" 4 Bernhard M. Wiedemann \f(CW@bmwiedemann\fR .IP "\(bu" 4 Brad Davidson \f(CW@brandond\fR .IP "\(bu" 4 Daniel Kahn Gillmor .IP "\(bu" 4 Daniel Risacher .IP "\(bu" 4 David O'Callaghan .IP "\(bu" 4 David Steinbrunner \f(CW@dsteinbrunner\fR .IP "\(bu" 4 dsteinwand .IP "\(bu" 4 Florian Schlichting \f(CW@fschlich\fR .IP "\(bu" 4 \&\s-1IKEDA\s0 Soji \f(CW@ikedas\fR .IP "\(bu" 4 James Hunt \f(CW@jhunt\fR .IP "\(bu" 4 James Rouzier \f(CW@jrouzierinverse\fR .IP "\(bu" 4 Johanna \f(CW@0xxon\fR .IP "\(bu" 4 Jonas Brømsø \f(CW@jonasbn\fR .IP "\(bu" 4 Louise Doran .IP "\(bu" 4 Michael McClimon \f(CW@mmcclimon\fR .IP "\(bu" 4 Michal Josef Špaček \f(CW@michal\fR\-josef\-spacek .IP "\(bu" 4 Neil Bowers \f(CW@neilb\fR .IP "\(bu" 4 Nicholas Harteau .IP "\(bu" 4 Otmar Lendl .IP "\(bu" 4 Patrick C. \f(CW@errror\fR .IP "\(bu" 4 Patrick Cernko .IP "\(bu" 4 Petr Pisar \f(CW@ppisar\fR .IP "\(bu" 4 pi-rho .IP "\(bu" 4 Salvador Fandiño \f(CW@salva\fR .IP "\(bu" 4 Sebastian Andrzej Siewior .IP "\(bu" 4 Sho Nakatani \f(CW@laysakura\fR .IP "\(bu" 4 Shoichi Kaji \f(CW@skaji\fR .IP "\(bu" 4 Timothy Legge \f(CW@timlegge\fR .IP "\(bu" 4 Todd Rinaldo \f(CW@toddr\fR .IP "\(bu" 4 Uli Scholler .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2004\-2022 by Dan Sully .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.