Skip to content

Commit 9350463

Browse files
authored
Merge pull request #5045 from hwupathum/refactor-pkcs12
Add docs to includes folder
2 parents 456fc20 + 6ff3a8d commit 9350463

18 files changed

+1689
-3332
lines changed
Lines changed: 1 addition & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1 @@
1-
# Change the hostname
2-
3-
This section guides you through changing the hostname of the WSO2 Identity Server.
4-
5-
1. Change the hostname - The server hostname for internal API calls is configured as `localhost` by default. This configuration is utilized to build the internal absolute URL of a service endpoint that will be consumed whenever internal API calls are generated. To configure the hostname, follow one of the two options given below according to your requirements.
6-
7-
**Option 1**
8-
9-
Configure the `hostname` as follows in `<IS_HOME>/repository/conf/deployment.toml`.
10-
11-
``` toml
12-
[server]
13-
hostname = "is.dev.wso2.com"
14-
```
15-
16-
Add `localhost` as SAN for the certificate (-ext SAN=dns:localhost) as the internal hostname is by default `localhost`. For that, navigate to the `<IS_HOME>/repository/resources/security` directory on the command prompt and use the following command to create a new keystore with `CN=is.dev.wso2.com` and `localhost` as SAN.
17-
18-
=== "Format"
19-
20-
``` java
21-
keytool -genkey -alias <alias_name> -keyalg RSA -keysize 2048 -keystore <keystore_name>.jks -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
22-
```
23-
24-
=== "Sample keytool command"
25-
26-
``` java
27-
keytool -genkey -alias newcert -keyalg RSA -keysize 2048 -keystore newkeystore.jks -dname "CN=is.dev.wso2.com, OU=Is,O=Wso2,L=SL,S=WS,C=LK" -storepass mypassword -keypass mypassword -ext SAN=dns:localhost
28-
```
29-
30-
**Option 2**
31-
32-
Instead of adding SAN, you can configure the same name for the `hostname`, and the `internal_hostname` in `<IS_HOME>/repository/conf/deployment.toml` as follows.
33-
34-
``` toml
35-
[server]
36-
hostname = "is.dev.wso2.com"
37-
internal_hostname = "is.dev.wso2.com"
38-
```
39-
40-
Navigate to the `<IS_HOME>/repository/resources/security` directory on the command prompt and use the following command to create a new keystore with `CN=is.dev.wso2.com`.
41-
42-
=== "Format"
43-
44-
``` java
45-
keytool -genkey -alias <alias_name> -keyalg RSA -keysize 2048 -keystore <keystore_name>.jks -dname "CN=<hostname>, OU=<organizational_unit>,O=<organization>,L=<Locality>,S=<State/province>,C=<country_code>" -storepass <keystore_password> -keypass <confirm_keystore_password>
46-
```
47-
48-
=== "Sample keytool command"
49-
50-
``` java
51-
keytool -genkey -alias newcert -keyalg RSA -keysize 2048 -keystore newkeystore.jks -dname "CN=is.dev.wso2.com, OU=Is,O=Wso2,L=SL,S=WS,C=LK" -storepass mypassword -keypass mypassword
52-
```
53-
54-
2. 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.toml` file in the `<IS_HOME>/repository/conf/` folder.
55-
56-
``` toml
57-
[keystore.primary]
58-
file_name = "new-keystore.jks"
59-
password = "new-keystore-password"
60-
alias = "new-private-key-alias"
61-
key_password = "new-private-key-password"
62-
```
63-
64-
3. Export the public key from your keystore .jks file using the following command.
65-
66-
=== "Format"
67-
68-
``` java
69-
keytool -export -alias <alias_name> -keystore <keystore_name>.jks -file <public_key_name>.pem
70-
```
71-
72-
=== "Sample keytool command"
73-
74-
``` java
75-
keytool -export -alias newcert -keystore newkeystore.jks -file pkn.pem
76-
```
77-
78-
4. Import the public key you extracted in the previous step to the `client-truststore.jks` file using the following command.
79-
80-
=== "Format"
81-
82-
``` java
83-
keytool -import -alias <alias_name> -file <public_key_name>.pem -keystore client-truststore.jks -storepass <keystore_password>
84-
```
85-
86-
=== "Sample keytool command"
87-
88-
``` java
89-
keytool -import -alias newcert -file pkn.pem -keystore client-truststore.jks -storepass wso2carbon
90-
```
91-
92-
!!! note
93-
If you create a new client truststore, in place of the default `client-truststore.jks`, place the new truststore in the `<IS_HOME>/repository/resources/security/` folder and add the following configuration to the `deployment.toml` file in the `<IS_HOME>/repository/conf/` folder.
94-
95-
```toml
96-
[truststore]
97-
file_name = "customer-truststore-name.jks"
98-
password = "password"
99-
```
100-
101-
5. Verify the hostname change by attempting to log in to My Account, getting a token from any grant type, etc.
102-
103-
6. 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.com` is an example in the sample entry below.
104-
105-
``` java
106-
127.0.0.1 is.dev.wso2.com
107-
```
108-
109-
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.jks`). 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.
110-
111-
**Option 1**
112-
113-
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).
114-
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]({{base_path}}/deploy/security/asymmetric-encryption/create-new-keystores/#step-2-import-certificates-to-the-keystore) topic to import it correctly.
115-
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.
116-
117-
**Option 2**
118-
119-
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]({{base_path}}/deploy/security/asymmetric-encryption/configure-keystores-in-wso2-products/) topic. This approach separates the keystores.
120-
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.
121-
122-
!!! note
123-
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.
124-
125-
Once this is done, you need to change all `localhost` references. The following points would be where the references should be changed.
126-
127-
- The configurations in the `<IS_HOME>/repository/conf/deployment.toml` file reference localhost.
128-
129-
<!-- TODO - Update the **Identity Provider Entity ID**
130-
131-
On the Management Console, go to **Identity Provider** > **Resident Identity Provider** > **Inbound Authentication Configuration** > **OAuth2/OpenID Connect Configuration** and update the **Identity Provider Entity ID** with any one of the following values:
132-
133-
- If you have added the proxy port as `443` to the `<IS_HOME>/repository/conf/deployment.toml` using the below configs, use `https://<DOMAIN>/oauth2/token` as the entity ID value.
134-
135-
```toml
136-
[transport.https.properties]
137-
proxyPort = 443
138-
```
139-
140-
- Else, use `https://<DOMAIN>:<PORT>/oauth2/token` as the entity ID value.-->
141-
142-
- The callback URLs of the federated identity providers.
143-
- The callback URLs of the default system applications such as My Account and Console.
144-
145-
!!! note
146-
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 change the callback URLs to use the new hostname.
147-
148-
To edit the default system applications such as My Account and Console, the following configuration should be added to the `<IS_HOME>/repository/conf/deployment.toml` file:
149-
150-
```toml
151-
[system_applications]
152-
read_only_apps = []
153-
```
1+
{% include "../../../../includes/deploy/change-the-hostname.md" %}

0 commit comments

Comments
 (0)