securityUtility command
The securityUtility command supports plain text encryption, SSL certificate creation, and creating LTPA keys for Liberty. Documentation for the securityUtility command in version 21.0.0.11 and later is available on the Open Liberty website.
Syntax
The command syntax is as follows:
- securityUtility task [options]
Notes
Different operating systems and command line environments treat some characters differently. In many environments, we can redefine which characters are special and how they behave. in your input string, it must be escaped by the caret character (^). The following example has a value of a! encoded.
- cd /path/to/wlp/bin
../securityUtility encode "a^!"
For some operating systems, we might need to use single quotation marks around arguments passed to the tool.
If we use a terminal emulator, make sure that your session is configured to use the same code page as the server.
Refer to the operating system, command shell, and terminal emulator documentation about special characters and code pages if you experience unexpected results.
Tasks
help
Print help information for a specified task.encode
Encodes the provided text using Base64. If no options are specified, the command enters interactive mode. Otherwise, the provided text is encoded. Text with spaces must be put in quotation marks.The options are:- name: The custom password encryption algorithm name.
- featurename: The feature name.
- description: The description of the custom password encryption.
--encoding=encoding_type | How to encode the password. Supported encodings are xor, aes, and hash. The default value is xor.
In version 25.0.0.1 and earlier, the aes type uses AES-128 encryption. We can use the hash encoding option to encode passwords for the basic user registry and the quickStartSecurity element.
hash options use enhanced algorithms to encrypt and encode strings. Strings that were encrypted or encoded with these options before the algorithms were enhanced might fail in FIPS 140-3 environments. |
--key=encryption_key | Key to be used when encoding with AES encryption. This string is hashed to produce an encryption key used to encrypt and decrypt the password. The key can be provided to the server by defining the variable wlp.password.encryption.key whose value is the key. If this option is not provided, a default key is used. |
--keyring | Key ring where the AES encryption key is stored when the z/OS Encryption Key feature is enabled to obtain the key. |
--keyringType | Type of the key ring specified by the --keyring flag when the z/OS Encryption Key feature is enabled to obtain the key. |
--keylabel | Name of the personal certificate entry to use as the AES encryption key when the z/OS Encryption Key feature is enabled to obtain the key. |
--listCustom | Display the information of the custom password encryption in JSON format.
|
--notrim | Specify whether space characters are removed from the beginning and end of the specified text. If this option is specified, the provided text is encoded as it is. If this option is not specified, space characters from the beginning and end of the specified text are removed. |
text | The text that is to be encoded. |
createSSLCertificate
Create a default keystore that includes an SSL certificate for use in a server or client configuration.Keystore details: | location: In the resource/security/key.p12 file of the server or client directory. | type: PKCS12 | In version 19.0.0.2 and earlier: location: In the resource/security/key.jks file of the server or client directory. | In version 19.0.0.2 and earlier: type: JKS | password: Password provided with the --password option. The password is needed to open the keystore file and retrieve the key from the keystore file. |
Certificate details: | type: Self-signed certificate. | size: 2048 by default, an alternative size can be specified with the --keySize option. | signature algorithm: SHA256withRSA, can be customized with the--sigAlg option. | validity: 365 days by default, can be customized with the --validity option. | SubjectDN: CN=<hostname>,OU=<client or server name>,O=ibm,C=us by default, can be customized with the --subject option. |
The options are:
--server=name | Name of the Liberty server for which the keystore and certificate is created. This option cannot be used if the --client option is specified. |
--client=name | Name of the Liberty client for which the keystore and certificate is created. This option cannot be used if the --server option is specified. |
--keyType=keystore type | Keystore type to generate. To generate a JKS keystore, specify the --keyType
option with the value of JKS. By default, a PKCS12 keystore is generated. However,
to explicitly specify the generation of a PKCS12 keystore, specify the --keyType option with the value of PKCS12.
A PKCS12 keystore has a number of advantages over a JKS keystore. The PKCS12 keystore is more extensible, supports stronger cryptographic algorithms, and is widely adopted. The PKCS12 format is frequently the format that certificate authorities provide when they issue certificates. |
--keySize=size | Certificate key bit size. The default value is 2048. |
--password=password | Password to be used in the keystore, which must be at least six characters in length. This option is required. |
--passwordEncoding=password_encoding_type | How to encode the keystore password. Supported encoding value is xor or aes. If this option is not provided, a default value of xor is used. |
--passwordkey=password_encryption_key | Key to use to encode the keystore password using AES encryption. This string is hashed to produce an encryption key used to encrypt and decrypt the password. The key can be provided to the server by defining the variable wlp.password.encryption.key whose value is the key. If this option is not provided, a default key is used. |
--validity=days | Number of days that the certificate is valid, which must be equal to or greater than 365. If this option is not provided, a default value of 365 is used. |
--subject=DN | Distinguished Name (DN) for the certificate subject and issuer. If this option is not provided, a default value of CN=<hostname>,OU=<server or client name>,O=ibm,C=us is used. The CN value is retrieved using a java method to get the machine's local hostname. If the hostname cannot be resolved, the IP address is returned. |
--sigAlg | Signature algorithm used to sign the self-signed certificate. The signature algorithm that is supported depends on what is supported by the underlying JRE. Stronger
signature algorithms might require the JRE to have the unrestricted policy file in place.
The command accepts SHA256withRSA (default), SHA1withRSA, SHA384withRSA, SHA512withRSA, SHA1withECDSA, SHA256withECDSA, SHA384withECDSA, and SHA512withECDSA. The signature algorithms that end with RSA creates certificates with RSA keys and the signature algorithms that end with ECDSA creates certificates with Elliptical Curve (EC) keys. Note: If we are using certificates created with EC keys, then the server needs a customized ciphers list in the ssl configuration to include EC ciphers. |
--extInfo | Specifies any X.509 certificate extension information that it uses to create the default certificate. By default, the Subject Alternative Name extension is added to the certificate with the host name of the server. If the --extInfo option is used, the value is passed directly to the keytool command. Use the syntax of the --ext flag on the keytool command. |
createLTPAKeys
Create a set of LTPA keys for use by the server, or that can be shared with multiple servers. If no server or file is specified, an ltpa.keys file is created in the current working directory.
The options are:
--file=name | The file in which to write the LTPA keys. This option can't be used if the --server option is specified. |
--passwordEncoding=password_encoding_type | How to encode the LTPA keys password in the server.xml file. Supported encoding types are xor and aes. If this option isn't specified, a default encoding type of xor is used. We can use the securityUtility encode --listCustom command to see if any additional custom encryptions are supported. |
--passwordKey=password_encryption_key | Key to use to encode an LTPA keys password with AES encryption. This string is hashed to produce an encryption key used to encrypt and decrypt the password. We can provide the key by defining the wlp.password.encryption.key variable as the key value. If this option isn't specified, a default key is used. |
--server=name | Name of the Open Liberty server for which the LTPA keys are created. This option can't be used if the --file option is specified. |
To create LTPA keys that use FIPS 140-3 approved algorithms, export the following system property before we run the createLTPAKeys command:
-
export JVM_ARGS="-Xenablefips140-3 -Dcom.ibm.jsse2.usefipsprovider=true -Dcom.ibm.jsse2.usefipsProviderName=IBMJCEPlusFIPS"
After the system properties are set, replace the existing LTPA keys with the newly created LTPA keys. For more information, see Set up Liberty for FIPS compliance.
Usage
The following examples demonstrate correct syntax:
securityUtility encode --encoding=aes GiveMeLiberty securityUtility createSSLCertificate --server=myserver --password=mypassword --validity=365 --subject=CN=mycompany,O=myOrg,C=myCountry securityUtility help createSSLCertificate securityUtility createLTPAKeys --password=mypassword
Parent topic: Create SSL certificates from the command line
Related tasks
- Secure Liberty and its applications
- Configure your web application and server for client certificate authentication
- Configure LDAP user registries in Liberty
- Configure a basic user registry for Liberty