Skip to content

Commit cd4ce60

Browse files
committed
Update concepts-networking-ssl-tls.md
1 parent 4b3fbdd commit cd4ce60

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

articles/postgresql/flexible-server/concepts-networking-ssl-tls.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,46 @@ System.setProperty("javax.net.ssl.trustStorePassword","password");
126126
> [!NOTE]
127127
> Azure Database for PostgreSQL - Flexible server doesn't support [certificate based authentication](https://www.postgresql.org/docs/current/auth-cert.html) at this time.
128128
129+
### Get list of trusted certificates in Java Key Store
130+
131+
As stated above, Java, by default, stores the trusted certificates in a special file named *cacerts* that is located inside Java installation folder on the client.
132+
Example below first reads *cacerts* and loads it into *KeyStore* object:
133+
```java
134+
private KeyStore loadKeyStore() {
135+
String relativeCacertsPath = "/lib/security/cacerts".replace("/", File.separator);
136+
String filename = System.getProperty("java.home") + relativeCacertsPath;
137+
FileInputStream is = new FileInputStream(filename);
138+
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
139+
String password = "changeit";
140+
keystore.load(is, password.toCharArray());
141+
142+
return keystore;
143+
}
144+
```
145+
The default password for *cacerts* is *changeit* , but should be different on real client, as administrators recommend changing password immediately after Java installation.
146+
Once we loaded KeyStore object, we can use the *PKIXParameters* class to read certificates present.
147+
```java
148+
public void whenLoadingCacertsKeyStore_thenCertificatesArePresent() {
149+
KeyStore keyStore = loadKeyStore();
150+
PKIXParameters params = new PKIXParameters(keyStore);
151+
Set<TrustAnchor> trustAnchors = params.getTrustAnchors();
152+
List<Certificate> certificates = trustAnchors.stream()
153+
.map(TrustAnchor::getTrustedCert)
154+
.collect(Collectors.toList());
155+
156+
assertFalse(certificates.isEmpty());
157+
}
158+
```
159+
### Updating Root certificates when using clients in Azure App Services with Azure Database for PostgreSQL - Flexible Server for certificate pinning scenarios
160+
161+
For Azure App services, connecting to Azure Database for PostgreSQL, we can have two possible scenarios on updating client certificates and it depends on how on you're using SSL with your application deployed to Azure App Services.
162+
163+
* Usually new certificates are added to App Service at platform level prior to changes in Azure Database for PostgreSQL - Flexible Server. If you are using the SSL certificates included on App Service platform in your application, then no action is needed. Consult following [Azure App Service documentation](../../app-service/configure-ssl-certificate.md) for more information.
164+
* If you're explicitly including the path to SSL cert file in your code, then you would need to download the new cert and update the code to use the new cert. A good example of this scenario is when you use custom containers in App Service as shared in the [App Service documentation](../../app-service/tutorial-multi-container-app.md#configure-database-variables-in-wordpress)
165+
166+
### Updating Root certificates when using clients in Azure Kubernetes Service (AKS) with Azure Database for PostgreSQL - Flexible Server for certificate pinning scenarios
167+
168+
If you're trying to connect to the Azure Database for PostgreSQL using applications hosted in Azure Kubernetes Services (AKS) and pinning certificates, it's similar to access from a dedicated customers host environment. Refer to the steps [here](../../aks/ingress-tls.md).
129169

130170
## Cipher Suites
131171

0 commit comments

Comments
 (0)