.nh .TH pki 1 "February 1, 2019" PKI "pki CLI" .SH NAME .PP pki \- Command\-Line Interface for accessing PKI services. .SH SYNOPSIS .PP \fBpki\fP [\fICLI\-options\fP] \fIcommand\fP [\fIcommand\-arguments\fP] .SH DESCRIPTION .PP The \fBpki\fP command provides a command\-line interface allowing clients to access various services on the PKI server. These services include certificates, groups, keys, security domains, and users. .SH CLI OPTIONS .PP \fB\-c\fP \fINSS\-database\-password\fP .br Specifies the NSS database password (mutually exclusive to the \fB\-C\fP option). .PP \fB\-C\fP \fINSS\-database\-password\-file\fP .br Specifies the file which contains the NSS database password (mutually exclusive to the \fB\-c\fP option). .PP \fB\-d\fP \fINSS\-database\-location\fP .br Specifies the NSS database location (default: \fI\∼/.dogtag/nssdb\fP). .PP \fB\-h\fP \fIhostname\fP .br Specifies the hostname (default: hostname of the local machine). .PP \fB\-\-help\fP .br Prints additional help information. .PP \fB\-\-ignore\-cert\-status\fP \fIlist\fP .br Comma\-separated list of ignored certificate validity statuses. Valid values are: .RS .IP \(bu 2 BAD\_CERT\_DOMAIN .IP \(bu 2 BAD\_KEY .IP \(bu 2 BAD\_SIGNATURE .IP \(bu 2 CA\_CERT\_INVALID .IP \(bu 2 CERT\_BAD\_ACCESS\_LOCATION .IP \(bu 2 CERT\_NOT\_IN\_NAME\_SPACE .IP \(bu 2 CERT\_STATUS\_SERVER\_ERROR .IP \(bu 2 EXPIRED\_CERTIFICATE .IP \(bu 2 EXPIRED\_ISSUER\_CERTIFICATE .IP \(bu 2 INADEQUATE\_CERT\_TYPE .IP \(bu 2 INADEQUATE\_KEY\_USAGE .IP \(bu 2 INVALID\_TIME .IP \(bu 2 OCSP\_BAD\_HTTP\_RESPONSE .IP \(bu 2 OCSP\_FUTURE\_RESPONSE .IP \(bu 2 OCSP\_MALFORMED\_REQUEST .IP \(bu 2 OCSP\_MALFORMED\_RESPONSE .IP \(bu 2 OCSP\_NO\_DEFAULT\_RESPONDER .IP \(bu 2 OCSP\_NOT\_ENABLED .IP \(bu 2 OCSP\_OLD\_RESPONSE .IP \(bu 2 OCSP\_REQUEST\_NEEDS\_SIG .IP \(bu 2 OCSP\_SERVER\_ERROR .IP \(bu 2 OCSP\_TRY\_SERVER\_LATER .IP \(bu 2 OCSP\_UNAUTHORIZED\_REQUEST .IP \(bu 2 OCSP\_UNKNOWN\_CERT .IP \(bu 2 OCSP\_UNKNOWN\_RESPONSE\_STATUS .IP \(bu 2 OCSP\_UNKNOWN\_RESPONSE\_TYPE .IP \(bu 2 OCSP\_UNAUTHORIZED\_RESPONSE .IP \(bu 2 PATH\_LEN\_CONSTRAINT\_INVALID .IP \(bu 2 REVOKED\_CERTIFICATE .IP \(bu 2 SEC\_ERROR\_CRL\_BAD\_SIGNATURE .IP \(bu 2 SEC\_ERROR\_CRL\_EXPIRED .IP \(bu 2 SEC\_ERROR\_CRL\_INVALID .IP \(bu 2 UNKNOWN\_ISSUER .IP \(bu 2 UNKNOWN\_SIGNER .IP \(bu 2 UNTRUSTED\_CERT .IP \(bu 2 UNTRUSTED\_ISSUER .RE .PP \fB\-\-message\-format\fP \fIformat\fP .br Message format: xml (default), json. .PP \fB\-n\fP \fIclient\-certificate\-nickname\fP .br Specifies the nickname for client certificate authentication (mutually exclusive to the \fB\-u\fP option). .PP \fB\-\-output\fP \fIfolder\fP .br Folder to store HTTP messages. .PP \fB\-P\fP \fIprotocol\fP .br Specifies the protocol (default: http). .PP \fB\-p\fP \fIport\fP .br Specifies the port (default: 8080). .PP \fB\-\-reject\-cert\-status\fP \fIlist\fP .br Comma\-separated list of rejected certificate validity statuses. .PP \fB\-t\fP \fItype\fP .br Subsystem type. .PP \fB\-\-token\fP \fItoken\fP .br Security token name .PP \fB\-U\fP \fIURL\fP .br Specifies the server URL. .PP \fB\-u\fP \fIusername\fP .br Specifies the username for basic authentication (mutually exclusive to the \fB\-n\fP option). .PP \fB\-v\fP, \fB\-\-verbose\fP .br Displays verbose information. .PP \fB\-\-version\fP .br Displays CLI version information. .PP \fB\-w\fP \fIpassword\fP .br Specifies the user password (mutually exclusive to the \fB\-W\fP option). .PP \fB\-W\fP \fIclient\-side\-password\-file\fP .br Specifies the file which contains the user password (mutually exclusive to the \fB\-w\fP option). .SH OPERATIONS .PP To view available commands and options, simply type \fBpki\fP\&. Some commands have sub\-\&commands. To view the sub\-\&commands, type \fBpki *command\fP*. To view each command's usage, type \fBpki \fIcommand\fP \-\-help\fP\&. .PP An NSS database is needed to execute commands that require crypto operations such as establishing SSL connection. See \fBpki\-client(1)\fP for more information. .SS Connection .PP By default, the CLI connects to a server running on the local machine via the non\-secure HTTP port 8080. To specify a different server location, use the appropriate arguments to give a different host (\fB\-h\fP), port (\fB\-p\fP), or connection protocol (\fB\-P\fP). .PP .RS .nf $ pki \-P \-h \-p .fi .RE .PP Alternatively, the connection parameters can be specified as a URI: .PP .RS .nf $ pki \-U .fi .RE .PP where the URI is of the format \fIprotocol\fP://\fIhostname\fP:\fIport\fP\&. .SH Authentication .PP Some commands require authentication. These are commands that are restricted to particular sets of users (such as agents or admins) or those operations involving certificate profiles that require authentication. .PP To execute a command without authentication: .PP .RS .nf $ pki .fi .RE .PP To execute a command using basic authentication (i.e. username/password), see the \fBBasic Authentication\fP section of this man page. .PP To execute a command using client authentication (i.e. client certificate), see the \fBClient Authentication\fP section of this man page. .SS Basic Authentication .PP To authenticate with a username and password: .PP .RS .nf $ pki \-u \-w .fi .RE .PP Rather than being exposed in plaintext on the command\-line, user passwords may be stored in a file instead. See \fBClient\-side Password Files\fP for detailed information. .PP To authenticate with a username by obtaining the user password from a client\-side password file: .PP .RS .nf $ pki \-u \-W .fi .RE .PP Finally, if a username has been specified on the command\-line, and neither the \fB\-W\fP \fIclient\-side\-password\-file\fP nor the \fB\-w\fP \fIpassword\fP options have been utilized, the password will be prompted for. .PP To authenticate with a username by interactively prompting for a password: .PP .RS .nf $ pki \-u .fi .RE .PP \fBNote:\fP Prompting for a user password is not suitable for automated batch processing. .SS Client Authentication Setup .PP A client certificate associated with the desired PKI server must be used for client authentication. This can be done by importing the client certificate into an NSS security database and passing the values to the relevant options provided by the \fBpki\fP CLI framework. .PP To achieve this, execute the following commands to set up an NSS database for use by the \fBpki\fP client, import the client certificate into the NSS database, and list information (including the nickname of the client certificate) stored in the NSS database: .PP .RS .nf $ certutil \-N \-d $ pk12util \-i \-d $ certutil \-L \-d .fi .RE .PP The first command creates an NSS database, and asks the client user to enter a password for this NSS database. .PP The second command imports a client certificate stored in a PKCS #12 format into this NSS database; it prompts for the passwords of the PKCS12 file and the NSS database. The simplest example of such a client certificate is to obtain the administrator certificate created during the configuration portion of the basic PKI installation of the associated PKI server (e.g. located at \fI/root/.dogtag/pki\-tomcat/ca\_admin\_cert.p12\fP on the PKI server machine). .PP The third command shows the information about the imported client certificate (including its nickname). .PP Additionally, provision the root CA certificate into this NSS DB. This certificate must be imported into the NSS DB and copied as a PEM format certificate into the NSS DB directory, named 'ca.crt'. To do so: .PP .RS .nf $ certutil \-A \-d \-n "CA Root Certificate" \-a \-i /path/to/ca.crt $ cp /path/to/ca.crt /ca.crt .fi .RE .PP This will ensure all parts of the client can successfully connect with the PKI instance and validate the certificate used to sign the web UI. If an external CA certificate was used to approve the sslserver certificate, import that certificate instead. .SS Client Authentication .PP To authenticate with a client certificate: .PP .RS .nf $ pki \-d \-c \-n .fi .RE .PP Alternatively, to prevent exposure via the command\-line, an NSS database may store their password in a file instead. See \fBClient\-side Password Files\fP for detailed information. .PP To authenticate with a client certificate by using the NSS database password stored in a file: .PP .RS .nf $ pki \-d \-C \-n .fi .RE .PP Finally, if a client certificate has been specified on the command\-line, and neither the \fB\-C\fP \fINSS\-database\-password\-file\fP nor the \fB\-c\fP \fINSS\-database\-password\fP options have been utilized, the NSS database password will be prompted for. .PP To authenticate with a client certificate by interactively prompting for an NSS database password: .PP .RS .nf $ pki \-d \-n .fi .RE .PP \fBNote:\fP Prompting for an NSS database password is not suitable for automated batch processing. .SS Client\-side Password Files .PP Both the \fB\-C\fP (client authentication) and the \fB\-W\fP (basic authentication) options require the use of a client\-side password file. .PP For security purposes, client\-side password files should be, at a minimum, operating system protected non\-world readable files. .PP Client\-side password files generally store a password in an equals\-sign\-delimited plaintext format 'token=password' (e.g. 'internal=foobar' where 'internal' is the token, '=' is the delimiter, and 'foobar' is the actual password). The token keyword 'internal' is the default specification for a token, and refers to the "Internal Key Storage Token". If a client\-side password file is being used for the sole purposes of the \fBpki\fP command\-line tool, a client\-side password file also supports the format that merely consists of the plaintext password on a single line (read the \fBCaveats\fP which follow). .PP \fBCaveats:\fP .PP Since client\-side password files are allowed to use the 'token=password' format, the first '=' character can only be used as a delimiter (i.e. it cannot be used as a valid character within the 'token' name) as escaping the '=' character within a token is not supported. .PP When specifying a password which contains an '=' character, always specify an initial '=' prior to specifying the actual password (mandatory when no token has been specified) as escaping the '=' character within a password is not supported. .PP Tokens do not support leading or trailing whitespace since these characters are stripped prior to their use; however, all whitespace inside tokens will be preserved. .PP Passwords preserve all leading, trailing, and internal whitespace since passwords are not trimmed prior to their use. .PP TBD: Supply code to handle the case of a non\-internal token (e.g. 'hardware\-nethsm' utilized in the following examples) since the current code ignores the specified token (i.e. it always utilizes the default 'internal' token no matter what is currently specified). .PP TBD: Allow numerous 'token=password' lines in a single client\-side password file to support the ability to authenticate against specified tokens as well as multiple tokens. .SS Valid examples include: .PP \fBinternal=foobar\fP .br where token="internal" and password="foobar" .PP \fBhardware\-nethsm=foobar\fP .br where token="hardware\-nethsm" (ignored \- TBD) and password="foobar" .PP \fBinternal=ack=bar\fP .br where token="internal" and password="ack=bar" .PP \fBhardware\-nethsm=ack=bar\fP .br where and token="hardware\-nethsm" (ignored \- TBD) and password="ack=bar" .PP \fB=foobar\fP .br where token="internal" (default) and password="foobar" .PP \fB=foo=bar\fP .br where token="internal" (default) and password="foo=bar" (Since the password contains an '=' character, an initial '=' character must be specified!) .PP \fBfoobar\fP .br where token="internal" (default) and password="foobar" .SS Results Paging .PP Some commands (e.g. cert\-find) may return multiple results. Since the number of results may be large, the results are split into multiple pages. By default the command will return only the first page (e.g. the first 20 results). To retrieve results from another page, additional paging parameters can be specified: .RS .IP \(bu 2 start: index of the first result to return (default: 0) .IP \(bu 2 size: number of results to return (default: 20) .RE .PP For example, to retrieve the first page (index #0\-#19): .PP .RS .nf $ pki cert\-find \-\-start 0 \-\-size 20 .fi .RE .PP To retrieve the second page (index #20\-#39): .PP .RS .nf $ pki cert\-find \-\-start 20 \-\-size 20 .fi .RE .PP To retrieve the third page (index #40\-#59): .PP .RS .nf $ pki cert\-find \-\-start 40 \-\-size 20 .fi .RE .SH FILES .PP \fI/usr/bin/pki\fP .SH SEE ALSO .PP \fBpki\-cert(1)\fP .br Certificate management commands .PP \fBpki\-client(1)\fP .br NSS database management commands .PP \fBpki\-group(1)\fP .br Group management commands .PP \fBpki\-group\-member(1)\fP .br Group member management commands .PP \fBpki\-key(1)\fP .br Key management commands .PP \fBpki\-securitydomain(1)\fP .br Security domain management commands .PP \fBpki\-user(1)\fP .br User management commands .PP \fBpki\-user\-cert(1)\fP .br User certificate management commands .PP \fBpki\-user\-membership(1)\fP .br User membership management commands .PP \fBpki\-ca\-profile(1)\fP .br Profile management commands .SH AUTHORS .PP Ade Lee \<alee@redhat.com\>, Endi Dewata \<edewata@redhat.com\>, and Matthew Harmsen \<mharmsen@redhat.com\>\&. .SH COPYRIGHT .PP Copyright (c) 2012 Red Hat, Inc. This is licensed under the GNU General Public License, version 2 (GPLv2). A copy of this license is available at http://www.gnu.org/licenses/old\-licenses/gpl\-2.0.txt.