Skip to content

Commit 70fd65a

Browse files
authored
Merge pull request #98726 from JasonFreeberg/patch-48
Better docs for Java Key Store
2 parents 60dba0c + 8fe5b7e commit 70fd65a

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

articles/app-service/containers/configure-language-java.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,37 @@ To inject these secrets in your Spring or Tomcat configuration file, use environ
234234
235235
### Using the Java Key Store
236236
237-
By default, any public or private certificates [uploaded to App Service Linux](../configure-ssl-certificate.md) will be loaded into the Java Key Store as the container starts. This means your uploaded certificates will be available in the connection context when making outbound TLS connections. After uploading your certificate, you will need to restart your App Service for it to be loaded into the Java Key Store.
237+
By default, any public or private certificates [uploaded to App Service Linux](../configure-ssl-certificate.md) will be loaded into the respective Java Key Stores as the container starts. After uploading your certificate, you will need to restart your App Service for it to be loaded into the Java Key Store. Public certificates are loaded into the Key Store at `$JAVA_HOME/jre/lib/security/cacerts`, and private certificates are stored in `$JAVA_HOME/lib/security/client.jks`.
238238
239-
You can interact or debug the Java Key Tool by [opening an SSH connection](app-service-linux-ssh-support.md) to your App Service and running the command `keytool`. See the [Key Tool documentation](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html) for a list of commands. The certificates are stored in Java's default keystore file location, `$JAVA_HOME/jre/lib/security/cacerts`.
240-
241-
Additional configuration may be necessary for encrypting your JDBC connection. Please refer to the documentation for your chosen JDBC driver.
239+
Additional configuration may be necessary for encrypting your JDBC connection with certificates in the Java Key Store. Please refer to the documentation for your chosen JDBC driver.
242240
243241
- [PostgreSQL](https://jdbc.postgresql.org/documentation/head/ssl-client.html)
244242
- [SQL Server](https://docs.microsoft.com/sql/connect/jdbc/connecting-with-ssl-encryption?view=sql-server-ver15)
245243
- [MySQL](https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-using-ssl.html)
246244
- [MongoDB](https://mongodb.github.io/mongo-java-driver/3.4/driver/tutorials/ssl/)
247245
- [Cassandra](https://docs.datastax.com/en/developer/java-driver/4.3/)
248246
249-
#### Manually initialize and load the key store
247+
#### Initializing the Java Key Store
248+
249+
To initialize the `import java.security.KeyStore` object, load the keystore file with the password. The default password for both key stores is "changeit".
250+
251+
```java
252+
KeyStore keyStore = KeyStore.getInstance("jks");
253+
keyStore.load(
254+
new FileInputStream(System.getenv("JAVA_HOME")+"/lib/security/cacets"),
255+
"changeit".toCharArray());
256+
257+
KeyStore keyStore = KeyStore.getInstance("pkcs12");
258+
keyStore.load(
259+
new FileInputStream(System.getenv("JAVA_HOME")+"/lib/security/client.jks"),
260+
"changeit".toCharArray());
261+
```
262+
263+
#### Manually load the key store
250264
251-
You can initialize the key store and add certificates manually. Create an app setting, `SKIP_JAVA_KEYSTORE_LOAD`, with a value of `1` to disable App Service from loading the certificates into the key store automatically. All public certificates uploaded to App Service via the Azure portal are stored under `/var/ssl/certs/`. Private certificates are stored under `/var/ssl/private/`.
265+
You can load certificates manually to the key store. Create an app setting, `SKIP_JAVA_KEYSTORE_LOAD`, with a value of `1` to disable App Service from loading the certificates into the key store automatically. All public certificates uploaded to App Service via the Azure portal are stored under `/var/ssl/certs/`. Private certificates are stored under `/var/ssl/private/`.
252266
253-
For more information on the KeyStore API, please refer to [the official documentation](https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html).
267+
You can interact or debug the Java Key Tool by [opening an SSH connection](app-service-linux-ssh-support.md) to your App Service and running the command `keytool`. See the [Key Tool documentation](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html) for a list of commands. For more information on the KeyStore API, please refer to [the official documentation](https://docs.oracle.com/javase/8/docs/api/java/security/KeyStore.html).
254268
255269
## Configure APM platforms
256270

0 commit comments

Comments
 (0)