{
    "content": [
        {
            "type": "text",
            "text": "# IO::Socket::SSL::Utils (perldoc)\n\n## NAME\n\nIO::Socket::SSL::Utils -- loading, storing, creating certificates and keys\n\n## SYNOPSIS\n\nuse IO::Socket::SSL::Utils;\n$cert = PEMfile2cert('cert.pem');     # load certificate from file\nmy $hash = CERTasHash($cert);         # get details from certificate\nPEMcert2file('cert.pem',$cert);       # write certificate to file\nCERTfree($cert);                      # free memory within OpenSSL\n@certs = PEMfile2certs('chain.pem');  # load multiple certificates from file\nPEMcerts2file('chain.pem', @certs);   # write multiple certificates to file\nCERTfree(@certs);                     # free memory for all within OpenSSL\nmy $cert = PEMstring2cert($pem);      # load certificate from PEM string\n$pem = PEMcert2string($cert);         # convert certificate to PEM string\n$key = KEYcreatersa(2048);           # create new 2048-bit RSA key\nPEMstring2file($key,\"key.pem\");       # and write it to file\nKEYfree($key);                        # free memory within OpenSSL\n\n## DESCRIPTION\n\nThis module provides various utility functions to work with certificates and private keys,\nshielding some of the complexity of the underlying Net::SSLeay and OpenSSL.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **FUNCTIONS**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "IO::Socket::SSL::Utils",
        "section": "",
        "mode": "perldoc",
        "summary": "IO::Socket::SSL::Utils -- loading, storing, creating certificates and keys",
        "synopsis": "use IO::Socket::SSL::Utils;\n$cert = PEMfile2cert('cert.pem');     # load certificate from file\nmy $hash = CERTasHash($cert);         # get details from certificate\nPEMcert2file('cert.pem',$cert);       # write certificate to file\nCERTfree($cert);                      # free memory within OpenSSL\n@certs = PEMfile2certs('chain.pem');  # load multiple certificates from file\nPEMcerts2file('chain.pem', @certs);   # write multiple certificates to file\nCERTfree(@certs);                     # free memory for all within OpenSSL\nmy $cert = PEMstring2cert($pem);      # load certificate from PEM string\n$pem = PEMcert2string($cert);         # convert certificate to PEM string\n$key = KEYcreatersa(2048);           # create new 2048-bit RSA key\nPEMstring2file($key,\"key.pem\");       # and write it to file\nKEYfree($key);                        # free memory within OpenSSL",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 179,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "IO::Socket::SSL::Utils -- loading, storing, creating certificates and keys\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use IO::Socket::SSL::Utils;\n\n$cert = PEMfile2cert('cert.pem');     # load certificate from file\nmy $hash = CERTasHash($cert);         # get details from certificate\nPEMcert2file('cert.pem',$cert);       # write certificate to file\nCERTfree($cert);                      # free memory within OpenSSL\n\n@certs = PEMfile2certs('chain.pem');  # load multiple certificates from file\nPEMcerts2file('chain.pem', @certs);   # write multiple certificates to file\nCERTfree(@certs);                     # free memory for all within OpenSSL\n\nmy $cert = PEMstring2cert($pem);      # load certificate from PEM string\n$pem = PEMcert2string($cert);         # convert certificate to PEM string\n\n$key = KEYcreatersa(2048);           # create new 2048-bit RSA key\nPEMstring2file($key,\"key.pem\");       # and write it to file\nKEYfree($key);                        # free memory within OpenSSL\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module provides various utility functions to work with certificates and private keys,\nshielding some of the complexity of the underlying Net::SSLeay and OpenSSL.\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "*   Functions converting between string or file and certificates and keys. They croak if the\noperation cannot be completed.\n\nPEMfile2cert(file) -> cert\nPEMcert2file(cert,file)\nPEMfile2certs(file) -> @certs\nPEMcerts2file(file,@certs)\nPEMstring2cert(string) -> cert\nPEMcert2string(cert) -> string\nPEMfile2key(file) -> key\nPEMkey2file(key,file)\nPEMstring2key(string) -> key\nPEMkey2string(key) -> string\n\n*   Functions for cleaning up. Each loaded or created cert and key must be freed to not leak\nmemory.\n\nCERTfree(@certs)\nKEYfree(@keys)\n\n*   KEYcreatersa(bits) -> key\n\nCreates an RSA key pair, bits defaults to 2048.\n\n*   KEYcreateec(curve) -> key\n\nCreates an EC key, curve defaults to \"prime256v1\".\n\n*   CERTasHash(cert,[digestalgo]) -> hash\n\nExtracts the information from the certificate into a hash and uses the given digestalgo\n(default: SHA-256) to determine digest of pubkey and cert. The resulting hash contains:\n\nsubject Hash with the parts of the subject, e.g. commonName, countryName, organizationName,\nstateOrProvinceName, localityName. If there are multiple values for any of these\nparts the hash value will be an array ref with the values in order instead of just a\nscalar.\n\nsubjectAltNames\nArray with list of alternative names. Each entry in the list is of \"[type,value]\",\nwhere \"type\" can be OTHERNAME, EMAIL, DNS, X400, DIRNAME, EDIPARTY, URI, IP or RID.\n\nissuer  Hash with the parts of the issuer, e.g. commonName, countryName, organizationName,\nstateOrProvinceName, localityName. If there are multiple values for any of these\nparts the hash value will be an array ref with the values in order instead of just a\nscalar.\n\nnotbefore, notafter\nThe time frame, where the certificate is valid, as timet, e.g. can be converted\nwith localtime or similar functions.\n\nserial  The serial number\n\ncrluri List of URIs for CRL distribution.\n\nocspuri\nList of URIs for revocation checking using OCSP.\n\nkeyusage\nList of keyUsage information in the certificate.\n\nextkeyusage\nList of extended key usage information from the certificate. Each entry in this list\nconsists of a hash with oid, nid, ln and sn.\n\npubkeydigestxxx\nBinary digest of the pubkey using the given digest algorithm, e.g.\npubkeydigestsha256 if (the default) SHA-256 was used.\n\nx509digestxxx\nBinary digest of the X.509 certificate using the given digest algorithm, e.g.\nx509digestsha256 if (the default) SHA-256 was used.\n\nfingerprintxxx\nFingerprint of the certificate using the given digest algorithm, e.g.\nfingerprintsha256 if (the default) SHA-256 was used. Contrary to digest* this is\nan ASCII string with a list if hexadecimal numbers, e.g. \"73:59:75:5C:6D...\".\n\nsignaturealg\nAlgorithm used to sign certificate, e.g. \"sha256WithRSAEncryption\".\n\next     List of extensions. Each entry in the list is a hash with oid, nid, sn, critical\nflag (boolean) and data (string representation given by X509V3EXTprint).\n\nversion Certificate version, usually 2 (x509v3)\n\n*   CERTcreate(hash) -> (cert,key)\n\nCreates a certificate based on the given hash. If the issuer is not specified the\ncertificate will be self-signed. The following keys can be given:\n\nsubject Hash with the parts of the subject, e.g. commonName, countryName, ... as described\nin \"CERTasHash\". Default points to IO::Socket::SSL.\n\nnotbefore\nA timet value when the certificate starts to be valid. Defaults to current time.\n\nnotafter\nA timet value when the certificate ends to be valid. Defaults to current time plus\none 365 days.\n\nserial  The serial number. If not given a random number will be used.\n\nversion The version of the certificate, default 2 (x509v3).\n\nCA true|false\nIf true declare certificate as CA, defaults to false.\n\npurpose string|array|hash\nSet the purpose of the certificate. The different purposes can be given as a string\nseparated by non-word character, as array or hash. With string or array each purpose\ncan be prefixed with '+' (enable) or '-' (disable) and same can be done with the\nvalue when given as a hash. By default enabling the purpose is assumed.\n\nIf the CA option is given and true the defaults \"ca,sslca,emailca,objca\" are\nassumed, but can be overridden with explicit purpose. If the CA option is given and\nfalse the defaults \"server,client\" are assumed. If no CA option and no purpose is\ngiven it defaults to \"server,client\".\n\nPurpose affects basicConstraints, keyUsage, extKeyUsage and netscapeCertType. The\nfollowing purposes are defined (case is not important):\n\nclient\nserver\nemail\nobjsign\n\nCA\nsslCA\nemailCA\nobjCA\n\nemailProtection\ncodeSigning\ntimeStamping\n\ndigitalSignature\nnonRepudiation\nkeyEncipherment\ndataEncipherment\nkeyAgreement\nkeyCertSign\ncRLSign\nencipherOnly\ndecipherOnly\n\nExamples:\n\n# root-CA for SSL certificates\npurpose => 'sslCA'   # or CA => 1\n\n# server certificate and CA (typically self-signed)\npurpose => 'sslCA,server'\n\n# client certificate\npurpose => 'client',\n\next [{ sn => .., data => ... }, ... ]\nList of extensions. The type of the extension can be specified as name with \"sn\" or\nas NID with \"nid\" and the data with \"data\". These data must be in the same syntax as\nexpected within openssl.cnf, e.g. something like \"OCSP;URI=http://...\". Additionally\nthe critical flag can be set with \"critical =\" 1>.\n\nkey key use given key as key for certificate, otherwise a new one will be generated and\nreturned\n\nissuercert cert\nset issuer for new certificate\n\nissuerkey key\nsign new certificate with given key\n\nissuer [ cert, key ]\nInstead of giving issuerkey and issuercert as separate arguments they can be given\nboth together.\n\ndigest algorithm\nspecify the algorithm used to sign the certificate, default SHA-256.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Steffen Ullrich\n",
                "subsections": []
            }
        }
    }
}