skip book previous and next navigation links
go up to top of book: HP Open Source Security for OpenVMS Volume 2:... HP Open Source Security for OpenVMS Volume 2:...
go to beginning of reference: OpenSSL Command Line Interface (CLI) Reference OpenSSL Command Line Interface (CLI) Reference
go to previous page: version version
go to next page: CRYPTO Application Programming Interface (API) ReferenceCRYPTO Application Programming Interface (API) Reference
end of book navigation links


x509
Description
Examples
Certificate Extensions
See Also
 Options
Notes
Restrictions

NAME

x509 - Certificate display and signing utility

Synopsis  

openssl x509 [-inform DER|PEM|NET] [-outform DER|PEM|NET] [-keyform DER|PEM] [-CAform DER|PEM] [-CAkeyform DER|PEM] [-in filename] [-out filename] [-serial] [-hash] [-subject] [-issuer] [-nameopt option] [-email] [-startdate] [-enddate] [-purpose] [-dates] [-modulus] [-fingerprint] [-alias] [-noout] [-trustout] [-clrtrust] [-clrreject] [-addtrust arg] [-addreject arg] [-setalias arg] [-days arg] [-set_serial n] [-signkey filename] [-x509toreq] [-req] [-CA filename] [-CAkey filename] [-CAcreateserial] [-CAserial filename] [-text] [-C] [-md2|-md5|-sha1|-mdc2] [-clrext] [-extfile filename] [-extensions section] [-engine id]


return to top DESCRIPTION  

The x509 command is a multi purpose certificate utility. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a "mini CA" or edit certificate trust settings.

Since there are a large number of options they will split up into various sections.


return to top OPTIONS  

INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS 

DISPLAY OPTIONS 

Note: the -alias and -purpose options are also display options but are described in the TRUST SETTINGS section.

TRUST SETTINGS 

Please note these options are currently experimental and may well change.

A trusted certificate is an ordinary certificate which has several additional pieces of information attached to it such as the permitted and prohibited uses of the certificate and an "alias".

Normally when a certificate is being verified at least one certificate must be "trusted". By default a trusted certificate must be stored locally and must be a root CA: any certificate chain ending in this CA is then usable for any purpose.

Trust settings currently are only used with a root CA. They allow a finer control over the purposes the root CA can be used for. For example a CA may be trusted for SSL client but not SSL server use.

See the description of the verify utility for more information on the meaning of trust settings.

Future versions of OpenSSL will recognize trust settings on any certificate: not just root CAs.

SIGNING OPTIONS 

The x509 utility can be used to sign certificates and requests: it can thus behave like a "mini CA".

NAME OPTIONS 

The nameopt command line switch determines how the subject and issuer names are displayed. If no nameopt switch is present the default "oneline" format is used which is compatible with previous versions of OpenSSL. Each option is described in detail below, all options can be preceded by a - to turn the option off. Only the first four will normally be used.

TEXT OPTIONS 

As well as customising the name output format, it is also possible to customise the actual fields printed using the certopt options when the text option is present. The default behaviour is to print all fields.


return to top EXAMPLES  

Note: in these examples the '\' means the example should be all on one line.

Display the contents of a certificate:

 openssl x509 -in cert.pem -noout -text
Display the certificate serial number:
 openssl x509 -in cert.pem -noout -serial
Display the certificate subject name:
 openssl x509 -in cert.pem -noout -subject
Display the certificate subject name in RFC2253 form:
 openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
Display the certificate subject name in oneline form on a terminal supporting UTF8:
 openssl x509 -in cert.pem -noout -subject -nameopt oneline,-escmsb
Display the certificate MD5 fingerprint:
 openssl x509 -in cert.pem -noout -fingerprint
Display the certificate SHA1 fingerprint:
 openssl x509 -sha1 -in cert.pem -noout -fingerprint
Convert a certificate from PEM to DER format:
 openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER
Convert a certificate to a certificate request:
 openssl x509 -x509toreq -in cert.pem -out req.pem -signkey key.pem
Convert a certificate request into a self signed certificate using extensions for a CA:
 openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \
	-signkey key.pem -out cacert.pem
Sign a certificate request using the CA certificate above and add user certificate extensions:
 openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \
	-CA cacert.pem -CAkey key.pem -CAcreateserial
Set a certificate to be trusted for SSL client use and change set its alias to "Steve's Class 1 CA"
 openssl x509 -in cert.pem -addtrust clientAuth \
	-setalias "Steve's Class 1 CA" -out trust.pem


return to top NOTES  

The PEM format uses the header and footer lines:
 -----BEGIN CERTIFICATE-----
 -----END CERTIFICATE-----
it will also handle files containing: 
 -----BEGIN X509 CERTIFICATE-----
 -----END X509 CERTIFICATE-----
Trusted certificates have the lines
 -----BEGIN TRUSTED CERTIFICATE-----
 -----END TRUSTED CERTIFICATE-----
The conversion to UTF8 format used with the name options assumes that T61Strings use the ISO8859-1 character set. This is wrong but Netscape and MSIE do this as do many certificates. So although this is incorrect it is more likely to display the majority of certificates correctly.

The -fingerprint option takes the digest of the DER encoded certificate. This is commonly called a "fingerprint". Because of the nature of message digests the fingerprint of a certificate is unique to that certificate and two certificates with the same fingerprint can be considered to be the same.

The Netscape fingerprint uses MD5 whereas MSIE uses SHA1.

The -email option searches the subject name and the subject alternative name extension. Only unique email addresses will be printed out: it will not print the same address more than once.


return to top CERTIFICATE EXTENSIONS  

The -purpose option checks the certificate extensions and determines what the certificate can be used for. The actual checks done are rather complex and include various hacks and workarounds to handle broken certificates and software.

The same code is used when verifying untrusted certificates in chains so this section is useful if a chain is rejected by the verify code.

The basicConstraints extension CA flag is used to determine whether the certificate can be used as a CA. If the CA flag is true then it is a CA, if the CA flag is false then it is not a CA. All CAs should have the CA flag set to true.

If the basicConstraints extension is absent then the certificate is considered to be a "possible CA" other extensions are checked according to the intended use of the certificate. A warning is given in this case because the certificate should really not be regarded as a CA: however it is allowed to be a CA to work around some broken software.

If the certificate is a V1 certificate (and thus has no extensions) and it is self signed it is also assumed to be a CA but a warning is again given: this is to work around the problem of Verisign roots which are V1 self signed certificates.

If the keyUsage extension is present then additional restraints are made on the uses of the certificate. A CA certificate must have the keyCertSign bit set if the keyUsage extension is present.

The extended key usage extension places additional restrictions on the certificate uses. If this extension is present (whether critical or not) the key can only be used for the purposes specified.

A complete description of each test is given below. The comments about basicConstraints and keyUsage and V1 certificates above apply to all CA certificates.


return to top Restrictions  

Extensions in certificates are not transferred to certificate requests and vice versa.

It is possible to produce invalid certificates or requests by specifying the wrong private key or using inconsistent options in some cases: these should be checked.

There should be options to explicitly set such things as start and end dates rather than an offset from the current time.

The code to implement the verify behaviour described in the TRUST SETTINGS is currently being developed. It thus describes the intended behaviour rather than the current behaviour. It is hoped that it will represent reality in OpenSSL 0.9.5 and later.


return to top SEE ALSO  

req(1) , ca(1) , genrsa(1) , gendsa(1) , verify(1)
go to previous page: version version
go to next page: CRYPTO Application Programming Interface (API) ReferenceCRYPTO Application Programming Interface (API) Reference