certtool - GnuTLS certificate tool
Usage: certtool [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
None:
-d, --debug=num Enable debugging
- it must be in the range:
0 to 9999
-V, --verbose More verbose output
--infile=file Input file
- file must pre-exist
--outfile=str Output file
--attime=str Perform validation at the timestamp instead of the system time
Certificate related options:
-i, --certificate-info Print information on the given certificate
--pubkey-info Print information on a public key
-s, --generate-self-signed Generate a self-signed certificate
-c, --generate-certificate Generate a signed certificate
--generate-proxy Generates a proxy certificate
-u, --update-certificate Update a signed certificate
--fingerprint Print the fingerprint of the given certificate
--key-id Print the key ID of the given certificate
--v1 Generate an X.509 version 1 certificate (with no extensions)
--sign-params=str Sign a certificate with a specific signature algorithm
Certificate request related options:
--crq-info Print information on the given certificate request
-q, --generate-request Generate a PKCS #10 certificate request
- prohibits the option 'infile'
--no-crq-extensions Do not use extensions in certificate requests
PKCS#12 file related options:
--p12-info Print information on a PKCS #12 structure
--p12-name=str The PKCS #12 friendly name to use
--to-p12 Generate a PKCS #12 structure
--pbmac1 Use PBMAC1 in a PKCS #12 structure
Private key related options:
-k, --key-info Print information on a private key
--p8-info Print information on a PKCS #8 structure
--to-rsa Convert an RSA-PSS key to raw RSA format
-p, --generate-privkey Generate a private key
--key-type=str Specify the key type to use on key generation
--key-format=str Specify the key format to use on key generation
--bits=num Specify the number of bits for key generation
--curve=str Specify the curve used for EC key generation
--sec-param=str Specify the security level [low, legacy, medium, high, ultra]
--to-p8 Convert a given key to a PKCS #8 structure
-8, --pkcs8 Use PKCS #8 format for private keys
--provable Generate a private key or parameters from a seed using a provable method
--verify-provable-privkey Verify a private key generated from a seed using a provable method
--seed=str When generating a private key use the given hex-encoded seed
CRL related options:
-l, --crl-info Print information on the given CRL structure
--generate-crl Generate a CRL
--verify-crl Verify a Certificate Revocation List using a trusted list
- requires the option 'load-ca-certificate'
Certificate verification related options:
-e, --verify-chain Verify a PEM encoded certificate chain
--verify Verify a PEM encoded certificate (chain) against a trusted set
--verify-hostname=str Specify a hostname to be used for certificate chain verification
--verify-email=str Specify a email to be used for certificate chain verification
- prohibits the option 'verify-hostname'
--verify-purpose=str Specify a purpose OID to be used for certificate chain verification
--verify-allow-broken Allow broken algorithms, such as MD5 for verification
--verify-profile=str Specify a security level profile to be used for verification
PKCS#7 structure options:
--p7-generate Generate a PKCS #7 structure
--p7-sign Signs using a PKCS #7 structure
--p7-detached-sign Signs using a detached PKCS #7 structure
--p7-include-cert The signer's certificate will be included in the cert list
- enabled by default
- disabled as '--no-p7-include-cert'
--p7-time Will include a timestamp in the PKCS #7 structure
--p7-show-data Will show the embedded data in the PKCS #7 structure
--p7-info Print information on a PKCS #7 structure
--p7-verify Verify the provided PKCS #7 structure
--smime-to-p7 Convert S/MIME to PKCS #7 structure
Other options:
--get-dh-params List the included PKCS #3 encoded Diffie-Hellman parameters
--dh-info Print information PKCS #3 encoded Diffie-Hellman parameters
--load-privkey=str Loads a private key file
--load-pubkey=str Loads a public key file
--load-request=str Loads a certificate request file
--load-certificate=str Loads a certificate file
--load-ca-privkey=str Loads the certificate authority's private key file
--load-ca-certificate=str Loads the certificate authority's certificate file
--load-crl=str Loads the provided CRL
--load-data=str Loads auxiliary data
--password=str Password to use
--null-password Enforce a NULL password
--empty-password Enforce an empty password
--hex-numbers Print big number in an easier format to parse
--cprint In certain operations it prints the information in C-friendly format
--hash=str Hash algorithm to use for signing
--salt-size=num Specify the RSA-PSS key default salt size
--label=str Specify the RSA-OAEP label, encoded in hexadecimal
--inder Use DER format for input certificates, private keys, and DH parameters
--inraw an alias for the 'inder' option
--outder Use DER format for output certificates, private keys, and DH parameters
--outraw an alias for the 'outder' option
--template=str Template file to use for non-interactive operation
--stdout-info Print information to stdout instead of stderr
--ask-pass Enable interaction for entering password when in batch mode
--pkcs-cipher=str Cipher to use for PKCS #8 and #12 operations
--provider=str Specify the PKCS #11 provider library
--text Output textual information before PEM-encoded certificates, private keys, etc
- enabled by default
- disabled as '--no-text'
Version, usage and configuration options:
-v, --version[=arg] output version information and exit
-h, --help display extended usage information and exit
-!, --more-help extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
Tool to parse and generate X.509 certificates, requests and private keys.
It can be used interactively or non interactively by
specifying the template command line option.
The tool accepts files or supported URIs via the --infile option. In case PIN
is required for URI access you can provide it using the environment variables GNUTLS_PIN
and GNUTLS_SO_PIN.
Please send bug reports to: <bugs@gnutls.org>
Options (93)
| Option | Description | Source |
|---|---|---|
-d, --debug num | Enable debugging. | help + man |
-V, --verbose | More verbose output. | help + man |
--infile file | Input file. | help + man |
--outfile str | Output file. | help + man |
--attime str | Perform validation at the timestamp instead of the system time. | help + man |
-i, --certificate-info | Print information on the given certificate. | help + man |
--pubkey-info | Print information on a public key. | help + man |
--generate-proxy | Generates a proxy certificate. | help + man |
-u, --update-certificate | Update a signed certificate. | help + man |
--fingerprint | Print the fingerprint of the given certificate. | help + man |
--key-id | Print the key ID of the given certificate. | help + man |
--v1 | Generate an X.509 version 1 certificate (with no extensions). | help + man |
--sign-params str | Sign a certificate with a specific signature algorithm. | help + man |
--crq-info | Print information on the given certificate request. | help + man |
-q, --generate-request | Generate a PKCS #10 certificate request. | help + man |
--no-crq-extensions | Do not use extensions in certificate requests. | help + man |
--p12-info | Print information on a PKCS #12 structure. | help + man |
--p12-name str | The PKCS #12 friendly name to use. | help + man |
--to-p12 | Generate a PKCS #12 structure. | help + man |
--pbmac1 | Use PBMAC1 in a PKCS #12 structure. | help + man |
-k, --key-info | Print information on a private key. | help + man |
--p8-info | Print information on a PKCS #8 structure. | help + man |
--to-rsa | Convert an RSA-PSS key to raw RSA format. | help + man |
-p, --generate-privkey | Generate a private key. | help + man |
--key-type str | Specify the key type to use on key generation. | help + man |
--key-format str | Specify the key format to use on key generation. | help + man |
--bits num | Specify the number of bits for key generation. | help + man |
--curve str | Specify the curve used for EC key generation. | help + man |
--sec-param str | Specify the security level [low, legacy, medium, high, ultra]. | help + man |
--to-p8 | Convert a given key to a PKCS #8 structure. | help + man |
-8, --pkcs8 | Use PKCS #8 format for private keys. | help + man |
--provable | Generate a private key or parameters from a seed using a provable method. | help + man |
--verify-provable-privkey | Verify a private key generated from a seed using a provable method. | help + man |
--seed str | When generating a private key use the given hex-encoded seed. | help + man |
-l, --crl-info | Print information on the given CRL structure. | help + man |
--generate-crl | Generate a CRL. | help + man |
--verify-crl | Verify a Certificate Revocation List using a trusted list. | help + man |
-e, --verify-chain | Verify a PEM encoded certificate chain. | help + man |
--verify | Verify a PEM encoded certificate (chain) against a trusted set. | help + man |
--verify-hostname str | Specify a hostname to be used for certificate chain verification. | help + man |
--verify-email str | Specify a email to be used for certificate chain verification. | help + man |
--verify-purpose str | Specify a purpose OID to be used for certificate chain verification. | help + man |
--verify-allow-broken | Allow broken algorithms, such as MD5 for verification. | help + man |
--verify-profile str | Specify a security level profile to be used for verification. | help + man |
--p7-generate | Generate a PKCS #7 structure. | help + man |
--p7-sign | Signs using a PKCS #7 structure. | help + man |
--p7-detached-sign | Signs using a detached PKCS #7 structure. | help + man |
--p7-include-cert, --no-p7-include-cert | The signer's certificate will be included in the cert list. | help + man |
--p7-time, --no-p7-time | Will include a timestamp in the PKCS #7 structure. | help + man |
--p7-show-data, --no-p7-show-data | Will show the embedded data in the PKCS #7 structure. | help + man |
--p7-info | Print information on a PKCS #7 structure. | help + man |
--p7-verify | Verify the provided PKCS #7 structure. | help + man |
--smime-to-p7 | Convert S/MIME to PKCS #7 structure. | help + man |
--get-dh-params | List the included PKCS #3 encoded Diffie-Hellman parameters. | help + man |
--dh-info | Print information PKCS #3 encoded Diffie-Hellman parameters. | help + man |
--load-privkey str | Loads a private key file. | help + man |
--load-pubkey str | Loads a public key file. | help + man |
--load-request str | Loads a certificate request file. | help + man |
--load-ca-privkey str | Loads the certificate authority's private key file. | help + man |
--load-crl str | Loads the provided CRL. | help + man |
--load-data str | Loads auxiliary data. | help + man |
--password str | Password to use. | help + man |
--null-password | Enforce a NULL password. | help + man |
--empty-password | Enforce an empty password. | help + man |
--hex-numbers | Print big number in an easier format to parse. | help + man |
--cprint | In certain operations it prints the information in C-friendly format. | help + man |
--hash str | Hash algorithm to use for signing. | help + man |
--salt-size num | Specify the RSA-PSS key default salt size. | help + man |
--label str | Specify the RSA-OAEP label, encoded in hexadecimal. | help + man |
--inder, --no-inder | Use DER format for input certificates, private keys, and DH parameters . | help + man |
--inraw | This is an alias for the --inder option. | help + man |
--outder, --no-outder | Use DER format for output certificates, private keys, and DH parameters. | help + man |
--outraw | This is an alias for the --outder option. | help + man |
--template str | Template file to use for non-interactive operation. | help + man |
--stdout-info | Print information to stdout instead of stderr. | help + man |
--ask-pass | Enable interaction for entering password when in batch mode. | help + man |
--pkcs-cipher str | Cipher to use for PKCS #8 and #12 operations. | help + man |
--provider str | Specify the PKCS #11 provider library. | help + man |
--text, --no-text | Output textual information before PEM-encoded certificates, private keys, etc. | help + man |
-v, --version arg | output version information and exit | help + man |
-h, --help | display extended usage information and exit | help + man |
--more-help | Pass the extended usage information through a pager. | help + man |
-s, --generate-self-signed | Generate a self-signed certificate. (in the manual page but not in --help) | man |
-c, --generate-certificate | Generate a signed certificate. (in the manual page but not in --help) | man |
--certificate-pubkey | Print certificate's public key. (in the manual page but not in --help) | man |
--generate-dh-params | Generate PKCS #3 encoded Diffie-Hellman parameters. (in the manual page but not in --help) | man |
--load-certificate str | Loads a certificate file. (in the manual page but not in --help) | man |
--load-ca-certificate str | Loads the certificate authority's certificate file. (in the manual page but not in --help) | man |
--rsa | Generate RSA key. (in the manual page but not in --help) | man |
--dsa | Generate DSA key. (in the manual page but not in --help) | man |
--ecc | Generate ECC (ECDSA) key. (in the manual page but not in --help) | man |
--ecdsa | This is an alias for the --ecc option. (in the manual page but not in --help) | man |
--disable-quick-random | No effect. (in the manual page but not in --help) | man |
Examples (19) from the manual page, untested
certtool --generate-privkey --outfile key.pem --rsa
Generating private keys To create an RSA private key, run:certtool --generate-request --load-privkey key.pem --outfile request.pem
Generating certificate requests To create a certificate request (needed when the certificate is issued by another party), run:./certtool --generate-request --load-privkey "pkcs11:..." --load-pubkey "pkcs11:..." --outfile request.pem
If the private key is stored in a smart card you can generate a request by specifying the private key object URL.certtool --generate-privkey --outfile ca-key.pem
Generating a self-signed certificate To create a self signed certificate, use the command:certtool --generate-self-signed --load-privkey ca-key.pem --outfile ca-cert.pem
Generating a self-signed certificate To create a self signed certificate, use the command:certtool --generate-certificate --load-request request.pem --outfile cert.pem --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem
Generating a certificate To generate a certificate using the previous request, use the command:certtool --generate-certificate --load-privkey key.pem --outfile cert.pem --load-ca-certificate ca-cert.pem --load-ca-privkey ca-key.pem
To generate a certificate using the private key only, use the command:certtool --certificate-info --infile cert.pem
Certificate information To view the certificate information, use:certtool --certificate-info --infile cert.pem --outder --outfile cert.der
Changing the certificate format To convert the certificate from PEM to DER format, use:certtool --load-certificate cert.pem --load-privkey key.pem --to-p12 --outder --outfile key.p12
PKCS #12 structure generation To generate a PKCS #12 structure using the previous key and certificate, use the command:certtool --load-ca-certificate ca.pem --load-certificate cert.pem --load-privkey key.pem --to-p12 --outder --outfile key.p12
Some tools (reportedly web browsers) have problems with that file because it does not contain the CA certificate for the certificate.certtool --get-dh-params --outfile dh.pem --sec-param medium
Obtaining Diffie-Hellman parameters To obtain the RFC7919 parameters for Diffie-Hellman key exchange, use the command:certtool --verify --infile cert.pem
Verifying a certificate To verify a certificate in a file against the system's CA trust store use the following command:certtool --verify --verify-hostname www.example.com --infile cert.pem
It is also possible to simulate hostname verification with the following options:certtool --generate-privkey > proxy-key.pem
Proxy certificate generation Proxy certificate can be used to delegate your credential to a temporary, typically short-lived, certificate.certtool --generate-proxy --load-ca-privkey key.pem --load-privkey proxy-key.pem --load-certificate cert.pem --outfile proxy-cert.pem
Proxy certificate generation Proxy certificate can be used to delegate your credential to a temporary, typically short-lived, certificate.certtool --generate-crl --load-ca-privkey x509-ca-key.pem --load-ca-certificate x509-ca.pem
Certificate revocation list generation To create an empty Certificate Revocation List (CRL) do:certtool --generate-crl --load-ca-privkey x509-ca-key.pem --load-ca-certificate x509-ca.pem --load-certificate revoked-certs.pem
To create a CRL that contains some revoked certificates, place the certificates in a file and use --load-certificate as follows:certtool --verify-crl --load-ca-certificate x509-ca.pem < crl.pem
To verify a Certificate Revocation List (CRL) do: