Change the hostname¶
This section guides you through changing the hostname of the WSO2 Identity Server.
-
Change the hostname - The server has two hostname configurations:
hostname- Use this to build public URLs for external-facing endpoints and APIs.internal_hostname- Use this to build internal URLs for internal service-to-service communication. Defaults tolocalhost.
Configure the hostname using one of the two options below.
Option 1
Configure the
hostnameas follows in<IS_HOME>/repository/conf/deployment.toml.Add both
localhostand the hostname to the SAN of the certificate (-ext SAN=dns:localhost,dns:<hostname>) as the internal hostname is by defaultlocalhost.Navigate to the
<IS_HOME>/repository/resources/securitydirectory on the command prompt and use the following command to create a new keystore withCN=is.dev.wso2.comand bothlocalhostandis.dev.wso2.comin the SAN.keytool -genkey -alias <alias_name> -keyalg RSA -keysize 2048 -keystore <keystore_name> -storetype <keystore_type> -dname "CN=<hostname>, OU=<organizational_unit>,O=<organization>,L=<Locality>,S=<State/province>,C=<country_code>" -storepass <keystore_password> -keypass <confirm_keystore_password> -ext SAN=dns:localhost,dns:<hostname>Option 2
Instead of adding
localhostto the SAN, you can configure the same name for thehostname, and theinternal_hostnamein<IS_HOME>/repository/conf/deployment.tomlas follows.Navigate to the
<IS_HOME>/repository/resources/securitydirectory on the command prompt and use the following command to create a new keystore withCN=is.dev.wso2.comandis.dev.wso2.comin the SAN.keytool -genkey -alias <alias_name> -keyalg RSA -keysize 2048 -keystore <keystore_name> -storetype <keystore_type> -dname "CN=<hostname>, OU=<organizational_unit>,O=<organization>,L=<Locality>,S=<State/province>,C=<country_code>" -storepass <keystore_password> -keypass <confirm_keystore_password> -ext SAN=dns:<hostname> -
If the keystore name and password is changed, all the references to it within the WSO2 Identity Server must also be updated. Add the following configuration to the
deployment.tomlfile in the<IS_HOME>/repository/conf/folder. -
Export the public key from your keystore file using the following command.
-
Import the public key you extracted in the previous step to the
client-truststore.p12file using the following command.Note
If you create a new client truststore, in place of the default
client-truststore.p12, place the new truststore in the<IS_HOME>/repository/resources/security/folder and add the following configuration to thedeployment.tomlfile in the<IS_HOME>/repository/conf/folder. -
Verify the hostname change by attempting to log in to My Account, getting a token from any grant type, etc.
-
If you are trying this on your local machine, open the
etc/hosts/file and add the following entry to map the new hostname.is.dev.wso2.comis an example in the sample entry below.
When you fully recreate the keystore, a new key-pair value is created. This means that any existing encrypted data (for example, users created before recreating the keystore) are still encrypted using the original keystore (wso2carbon.p12). Therefore, older users will not be able to log in to My Account and need to be migrated. You can use one of the following options in this situation.
Option 1
Change the hostname. The hostname is part of the Subject of the Certificate (i.e., it is not part of the original key pair). Therefore, you can use the same public and private key pair to generate a new CSR with the updated CN (subject).
This can be done by adding the -dname option when -certreq is executed. Once the CA certificate is obtained, follow the instructions given in the importing certificates to the keystore topic to import it correctly.
By doing that, you do not need to touch the key pair, and any other operations performed using the same key pair, such as encryption, will not be affected.
Option 2
Create a new keystore with the instructions for the new hostname and then use that keystore for SSL/TLS by changing the Tomcat connector configuration as described in the Configure Keystores topic. This approach separates the keystores. The secondary keystore with the new hostname will only be used for Tomcat SSL/TLS communication, while the primary one will be used for all other operations (encryption, etc.). By doing this, you can ensure the existing encrypted data is not affected.
Note
If you have chosen Option 2, you need to maintain and secure the two keystores. Hence, Option 1 is recommended unless you prefer separation of keys used in SSL/TLS communication and internal data encryption, signing, etc.
Once this is done, you need to change all localhost references. The following points would be where the references should be changed.
- The configurations in the
<IS_HOME>/repository/conf/deployment.tomlfile reference localhost.
- The callback URLs of the federated identity providers.
- The callback URLs of the default system applications such as My Account and Console.
Note
By default, both the My Account and the Console Applications use the localhost:9443 domain within the callback URL. When you change the hostname, the WSO2 Identity Server will not be running on the localhost:9443 domain, and these values will not automatically change. Hence, you should manually update the callback URLs in the <IS_HOME>/repository/conf/deployment.toml file to use the new hostname.
Add the following configuration to the <IS_HOME>/repository/conf/deployment.toml file to update the callback URLs for My Account and Console:
[console]
callback_url = "https://<NEW_HOSTNAME>:<PORT>/console"
[myaccount]
callback_url = "https://<NEW_HOSTNAME>:<PORT>/myaccount"
Replace <NEW_HOSTNAME> with your configured hostname (for example, is.dev.wso2.com) and <PORT> with your port number (for example, 9443).