IO::Socket::SSL::Utils - Online Linux Manual PageSection : 3
Updated : 2023-01-25
Source : perl v5.36.0
Note : User Contributed Perl Documentation
NAMEIO::Socket::SSL::Utils −− loading, storing, creating certificates and keys
SYNOPSIS use IO::Socket::SSL::Utils;
$cert = PEM_file2cert('cert.pem'); # load certificate from file
my $hash = CERT_asHash($cert); # get details from certificate
PEM_cert2file($cert,'cert.pem'); # write certificate to file
CERT_free($cert); # free memory within OpenSSL
@certs = PEM_file2certs('chain.pem'); # load multiple certificates from file
PEM_certs2file('chain.pem', @certs); # write multiple certificates to file
CERT_free(@certs); # free memory for all within OpenSSL
my $cert = PEM_string2cert($pem); # load certificate from PEM string
$pem = PEM_cert2string($cert); # convert certificate to PEM string
$key = KEY_create_rsa(2048); # create new 2048−bit RSA key
PEM_key2file($key,"key.pem"); # and write it to file
KEY_free($key); # free memory within OpenSSL
DESCRIPTIONThis module provides various utility functions to work with certificates and private keys, shielding some of the complexity of the underlying Net::SSLeay and OpenSSL.
FUNCTIONS• Functions converting between string or file and certificates and keys. They croak if the operation cannot be completed. PEM_file2cert(file) −> cert PEM_cert2file(cert,file) PEM_file2certs(file) −> @certs PEM_certs2file(file,@certs) PEM_string2cert(string) −> cert PEM_cert2string(cert) −> string PEM_file2key(file) −> key PEM_key2file(key,file) PEM_string2key(string) −> key PEM_key2string(key) −> string • Functions for cleaning up. Each loaded or created cert and key must be freed to not leak memory. CERT_free(@certs) KEY_free(@keys) • KEY_create_rsa(bits) −> key Creates an RSA key pair, bits defaults to 2048. • KEY_create_ec(curve) −> key Creates an EC key, curve defaults to \*(C`prime256v1\*(C'\fR. • CERT_asHash(cert,[digest_algo]) −> hash Extracts the information from the certificate into a hash and uses the given digest_algo (default: SHA−256) to determine digest of pubkey and cert. The resulting hash contains: subject Hash with the parts of the subject, e.g. commonName, countryName, organizationName, stateOrProvinceName, localityName. If there are multiple values for any of these parts the hash value will be an array ref with the values in order instead of just a scalar. subjectAltNames Array with list of alternative names. Each entry in the list is of \*(C`[type,value]\*(C'\fR, where \f(CW\*(C`type\*(C'\fR can be OTHERNAME, EMAIL, DNS, X400, DIRNAME, EDIPARTY, URI, IP or RID. issuer Hash with the parts of the issuer, e.g. commonName, countryName, organizationName, stateOrProvinceName, localityName. If there are multiple values for any of these parts the hash value will be an array ref with the values in order instead of just a scalar. not_before, not_after The time frame, where the certificate is valid, as time_t, e.g. can be converted with localtime or similar functions. serial The serial number crl_uri List of URIs for CRL distribution. ocsp_uri List of URIs for revocation checking using OCSP. keyusage List of keyUsage information in the certificate. extkeyusage List of extended key usage information from the certificate. Each entry in this list consists of a hash with oid, nid, ln and sn. pubkey_digest_xxx Binary digest of the pubkey using the given digest algorithm, e.g. pubkey_digest_sha256 if (the default) SHA−256 was used. x509_digest_xxx Binary digest of the X.509 certificate using the given digest algorithm, e.g. x509_digest_sha256 if (the default) SHA−256 was used. fingerprint_xxx Fingerprint of the certificate using the given digest algorithm, e.g. fingerprint_sha256 if (the default) SHA−256 was used. Contrary to digest_* this is an ASCII string with a list if hexadecimal numbers, e.g. "73:59:75:5C:6D...". signature_alg Algorithm used to sign certificate, e.g. \*(C`sha256WithRSAEncryption\*(C'\fR. ext List of extensions. Each entry in the list is a hash with oid, nid, sn, critical flag (boolean) and data (string representation given by X509V3_EXT_print). version Certificate version, usually 2 (x509v3) • CERT_create(hash) −> (cert,key) Creates a certificate based on the given hash. If the issuer is not specified the certificate will be self-signed. The following keys can be given: subject Hash with the parts of the subject, e.g. commonName, countryName, ... as described in \*(C`CERT_asHash\*(C'\fR. Default points to IO::Socket::SSL. not_before A time_t value when the certificate starts to be valid. Defaults to current time. not_after A time_t value when the certificate ends to be valid. Defaults to current time plus one 365 days. serial The serial number. If not given a random number will be used. version The version of the certificate, default 2 (x509v3). CA true|false If true declare certificate as CA, defaults to false. purpose string|array|hash Set the purpose of the certificate. The different purposes can be given as a string separated by non-word character, as array or hash. With string or array each purpose can be prefixed with '+' (enable) or '−' (disable) and same can be done with the value when given as a hash. By default enabling the purpose is assumed. If the CA option is given and true the defaults "ca,sslca,emailca,objca" are assumed, but can be overridden with explicit purpose. If the CA option is given and false the defaults "server,client" are assumed. If no CA option and no purpose is given it defaults to "server,client". Purpose affects basicConstraints, keyUsage, extKeyUsage and netscapeCertType. The following purposes are defined (case is not important): client
server
email
objsign
CA
sslCA
emailCA
objCA
emailProtection
codeSigning
timeStamping
digitalSignature
nonRepudiation
keyEncipherment
dataEncipherment
keyAgreement
keyCertSign
cRLSign
encipherOnly
decipherOnly
Examples: # root−CA for SSL certificates
purpose => 'sslCA' # or CA => 1
# server certificate and CA (typically self−signed)
purpose => 'sslCA,server'
# client certificate
purpose => 'client',
ext [{ sn => .., data => ... }, ... ] List of extensions. The type of the extension can be specified as name with \*(C`sn\*(C'\fR or as NID with \f(CW\*(C`nid\*(C'\fR and the data with \f(CW\*(C`data\*(C'\fR. These data must be in the same syntax as expected within openssl.cnf, e.g. something like \*(C`OCSP;URI=http://...\*(C'\fR. Additionally the critical flag can be set with \*(C`critical =\*(C'\fR 1>. key key use given key as key for certificate, otherwise a new one will be generated and returned issuer_cert cert set issuer for new certificate issuer_key key sign new certificate with given key issuer [ cert, key ] Instead of giving issuer_key and issuer_cert as separate arguments they can be given both together. digest algorithm specify the algorithm used to sign the certificate, default SHA−256.
AUTHORSteffen Ullrich 0
Johanes Gumabo
Data Size : 24,976 byte
man-IO::Socket::SSL::Utils.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 4 / 171,395
Visitor ID : :
Visitor IP : 3.143.237.54 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|IO::Socket::SSL::Utils.3pm|24/25|el══─{─══.|.el══─{─══. ds C`
) (htmlprn|149|IO::Socket::SSL::Utils.3pm|24/25|.el══─{─══. ds C` |.el══─{─══. ds C`
) (parse_manual_page_|249|IO::Socket::SSL::Utils.3pm|27|br══─}─══|'br══─}─══
) (htmlprn|149|IO::Socket::SSL::Utils.3pm|27|'br══─}─══ |'br══─}─══
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|143|\*(C`prime256v1\*(C'\fR. |Creates an EC key, curve defaults to \f(CW\*(C`prime256v1\*(C'\fR.
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|160|\*(C`[type,value]\*(C'\fR, where \f(CW\*(C`type\*(C'\fR can be OTHERNAME, EMAIL, DNS, X400, DIRNAME, |\&\f(CW\*(C`[type,value]\*(C'\fR, where \f(CW\*(C`type\*(C'\fR can be OTHERNAME, EMAIL, DNS, X400, DIRNAME,
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|204|\*(C`sha256WithRSAEncryption\*(C'\fR. |Algorithm used to sign certificate, e.g. \f(CW\*(C`sha256WithRSAEncryption\*(C'\fR.
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|226|\*(C`CERT_asHash\*(C'\fR. |described in \f(CW\*(C`CERT_asHash\*(C'\fR.
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|302|\*(C`sn\*(C'\fR or as NID with \f(CW\*(C`nid\*(C'\fR and the data with \f(CW\*(C`data\*(C'\fR. These data must be in the |\&\f(CW\*(C`sn\*(C'\fR or as NID with \f(CW\*(C`nid\*(C'\fR and the data with \f(CW\*(C`data\*(C'\fR. These data must be in the
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|304|\*(C`OCSP;URI=http://...\*(C'\fR. Additionally the critical flag can be set with |\&\f(CW\*(C`OCSP;URI=http://...\*(C'\fR. Additionally the critical flag can be set with
) (rof_escape_sequence|91|IO::Socket::SSL::Utils.3pm|305|\*(C`critical =\*(C'\fR 1>. |\&\f(CW\*(C`critical =\*(C'\fR 1>.
)