Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End to end TLS SSL #16452

Merged
merged 94 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
9011247
Add JCA provider for Azure KeyVault
mnriem Sep 16, 2020
366021a
Added the starter
mnriem Sep 29, 2020
4229ad5
Added sample
mnriem Sep 30, 2020
7720e9c
Cleaned up sample
mnriem Sep 30, 2020
f4294f9
Remove unncessary deployment.yml
mnriem Sep 30, 2020
49239ee
Add system assigned identity support step #1
mnriem Oct 1, 2020
502bd87
Added system managed identity support for App Service
mnriem Oct 2, 2020
599b7ed
Added README for JCA provider
mnriem Oct 6, 2020
d8d0bc0
Added README for JCA provider
mnriem Oct 6, 2020
316bd95
Add instructions to build starter
mnriem Oct 6, 2020
0c0c67a
Add instructions to build starter
mnriem Oct 6, 2020
d4a5a1f
Add instructions to build starter
mnriem Oct 6, 2020
95aea0e
Add instructions to build starter
mnriem Oct 6, 2020
7fc2946
Add instructions to build starter
mnriem Oct 6, 2020
b7dcb07
Minor fixes
mnriem Oct 6, 2020
8da02d2
Added setDelegate
mnriem Oct 6, 2020
8bece1f
Added logging
mnriem Oct 7, 2020
0c3e63f
Added more logging
mnriem Oct 8, 2020
f0624cf
Added more logging
mnriem Oct 8, 2020
8ec0bc7
Added configuration for Spring Cloud gateway
mnriem Oct 8, 2020
8dbd7ac
Added creating an Azure KeyVault section
mnriem Oct 8, 2020
132ec36
Add instructions to create a self-signed certificate
mnriem Oct 8, 2020
bec1cf6
Add 'assign a managed identity'
mnriem Oct 8, 2020
da1774b
Add instructions to grant a managed identity access to keyvault
mnriem Oct 8, 2020
c89d604
Add link to JCA provider
mnriem Oct 8, 2020
f9d0dd5
Added link to JCA reference guide
mnriem Oct 9, 2020
61c8a19
Add link to our Spring Boot starter
mnriem Oct 9, 2020
53316f3
Make sure server.ssl.key-store and server.ssl.trust-store are set aut…
mnriem Oct 9, 2020
ea2eb04
Fix Spring Boot starter link
mnriem Oct 9, 2020
fa393b1
Merge branch 'end-to-end-tls-ssl' of https://github.com/selvasingh/az…
mnriem Oct 9, 2020
716acd7
Reworked logging
mnriem Oct 13, 2020
10e0010
Reworked logging
mnriem Oct 13, 2020
7367231
Added certificate side-loading
mnriem Oct 13, 2020
809cc34
Add logging for side-loading
mnriem Oct 13, 2020
8078ad4
Add logging for side-loading
mnriem Oct 13, 2020
99b94da
Add README content for side-loading
mnriem Oct 14, 2020
653933b
Add README content for side-loading
mnriem Oct 14, 2020
d7f1606
Add statement what to do when Spring Cloud Config server is in the mix
mnriem Oct 14, 2020
fff173c
Add logging of KeyVault URI
mnriem Oct 14, 2020
bbfdc10
Programmatically determine whether or not using Tomcat
mnriem Oct 14, 2020
f8ee1b0
Added KeyVault TrustManagerFactory
mnriem Oct 15, 2020
ebccc65
Added KeyVault TrustManagerFactory
mnriem Oct 15, 2020
4391b3e
Updated groupId
mnriem Oct 16, 2020
afb7883
Updated artificatId
mnriem Oct 16, 2020
a96ae4d
Updated package names
mnriem Oct 16, 2020
abbf13d
Add KeyVault URI to Spring Cloud Gateway snippet
mnriem Oct 16, 2020
73f25b2
Allow for disabling hostname verification
mnriem Oct 16, 2020
4d9d1ee
Change properties to include JCA 'namespace' in it
mnriem Oct 16, 2020
0da1ecc
Add core principles
mnriem Oct 16, 2020
414a7fb
Add core principles
mnriem Oct 16, 2020
221f655
Add core principles
mnriem Oct 16, 2020
70bab18
Minor renaming of project to reflect it is a JCA provider for Azure K…
mnriem Oct 16, 2020
026d386
No logic change, just format xml file.
rujche Oct 19, 2020
92fec34
Fix error reported by pom_file_version_scanner.ps1.
rujche Oct 19, 2020
309bb8e
Format file in sdk/spring/azure-spring-boot-starter-keyvault-certific…
rujche Oct 19, 2020
309af4f
Format files in sdk/keyvault/azure-security-keyvault-jca.
rujche Oct 19, 2020
ecfe01d
Format files in sdk/spring/azure-spring-boot-samples/azure-spring-boo…
rujche Oct 19, 2020
8653364
Change groupId from com.azure.spring to com.azure.
rujche Oct 19, 2020
851ae20
Add new projects in to root pom modules.
rujche Oct 19, 2020
d52fe29
Merge branch 'master' into end-to-end-tls-ssl
rujche Oct 19, 2020
5870ffe
Update CHANGELOG.md and README.md.
rujche Oct 19, 2020
539e5df
Add version tag in azure-security-keyvault-jca\pom.xml.
rujche Oct 19, 2020
dc057a0
No logic change, just make code easier to read.
rujche Oct 19, 2020
274b2ed
No logic change, just make code easier to read.
rujche Oct 19, 2020
4d6a973
No logic change, just make code easier to read.
rujche Oct 19, 2020
4f0dbad
No logic change, just make code easier to read.
rujche Oct 19, 2020
67bdb82
No logic change, just make code easier to read.
rujche Oct 19, 2020
bdd4047
Delete unused files.
rujche Oct 19, 2020
6867d33
No logic change.
rujche Oct 19, 2020
8a2ab04
Update release version and current version of 'azure-spring-boot-star…
rujche Oct 19, 2020
3f8c152
Update README.md.
rujche Oct 19, 2020
74306ec
1. Set azure-security-keyvault-jca's version to 1.0.0-beta.1.
rujche Oct 19, 2020
039d92c
No logic change.
rujche Oct 19, 2020
4c3a3a7
Change azure-spring-boot-sample-keyvault-certificates's groupId to co…
rujche Oct 19, 2020
eee1baf
Skip maven-surefire-plugin by default.
rujche Oct 19, 2020
f1568c2
Change azure-spring-boot-starter-keyvault-certificates's version to 3…
rujche Oct 19, 2020
625c50f
Fix groupId error about httpclient5.
rujche Oct 19, 2020
5c90b80
Changes to accomodate X509ExtendedTrustManager
mnriem Oct 19, 2020
767c662
Restore Dockerfile
mnriem Oct 19, 2020
ee6952d
Comment out links for now
mnriem Oct 19, 2020
30df750
Add package-info for the starter
mnriem Oct 19, 2020
41ada7f
Add parent POMs back to see what else fails
mnriem Oct 19, 2020
5198b86
Updates for pipeline
mnriem Oct 19, 2020
2438787
Updates for pipeline
mnriem Oct 19, 2020
5dc3b16
Allow for given dependencies
mnriem Oct 19, 2020
da408a1
Make build pass
mnriem Oct 19, 2020
df48b76
Make build pass
mnriem Oct 19, 2020
51e9ada
Make build pass
mnriem Oct 19, 2020
966ba73
Make build pass
mnriem Oct 19, 2020
75e4186
Make build pass
mnriem Oct 19, 2020
22916a8
Make build pass
mnriem Oct 19, 2020
ea0d71b
Add 2 new artifact into ci.yml.
rujche Oct 20, 2020
01a5613
Fix error in pipeline.
rujche Oct 20, 2020
59b9585
Removed @author
mnriem Oct 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ ClientAggregatePom.xml

# Anaconda virtual env
venv

# NetBeans
nbproject
nb-configuration.xml
3 changes: 3 additions & 0 deletions eng/versioning/external_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ org.apache.avro:avro-maven-plugin;1.9.2
org.apache.commons:commons-compress;1.20
org.apache.commons:commons-lang3;3.10
org.apache.httpcomponents:httpclient;4.5.12
org.apache.httpcomponents.client5:httpclient5;5.0.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears as if this dependency is being used in a shaded fashion, alongside other libraries. I would be happier if we didn't need these dependencies at all though. From a quick look through the code it doesn't appear to be baked in deeply, mainly showing up it seems in the LegacyRestClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencies of the JCA provider are shaded to make sure the provider is self-contained and can be used in any Java application

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, understood. My comment was mainly focused on whether the httpclient is necessary in the first place? It doesn't appear to be from a cursory glance.

org.apache.logging.log4j:log4j-api;2.13.3
org.apache.logging.log4j:log4j-core;2.13.3
org.apache.logging.log4j:log4j-slf4j-impl;2.13.3
Expand All @@ -79,6 +80,7 @@ org.powermock:powermock-api-mockito2;2.0.2
org.powermock:powermock-module-junit4;2.0.2
org.postgresql:postgresql;42.2.14
org.slf4j:slf4j-api;1.7.30
org.slf4j:slf4j-nop;1.7.30
org.slf4j:slf4j-simple;1.7.30

## Spring boot dependency versions
Expand Down Expand Up @@ -232,6 +234,7 @@ org.apache.maven.plugins:maven-jxr-plugin;3.0.0
org.apache.maven.plugins:maven-project-info-reports-plugin;3.0.0
org.apache.maven.plugins:maven-release-plugin;2.5.3
org.apache.maven.plugins:maven-resources-plugin;2.4.3
org.apache.maven.plugins:maven-shade-plugin;3.2.4
org.apache.maven.plugins:maven-site-plugin;3.7.1
org.apache.maven.plugins:maven-source-plugin;3.0.1
org.apache.maven.plugins:maven-surefire-plugin;3.0.0-M3
Expand Down
2 changes: 2 additions & 0 deletions eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ com.azure:azure-search-documents;11.1.1;11.2.0-beta.3
com.azure:azure-search-perf;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-security-keyvault-administration;4.0.0-beta.2;4.0.0-beta.3
com.azure:azure-security-keyvault-certificates;4.1.2;4.2.0-beta.3
com.azure:azure-security-keyvault-jca;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-security-keyvault-keys;4.2.2;4.3.0-beta.3
com.azure:azure-security-keyvault-secrets;4.2.2;4.3.0-beta.3
com.azure:azure-sdk-template;1.2.1-beta.2;1.2.1-beta.16
Expand All @@ -66,6 +67,7 @@ com.azure.spring:azure-spring-boot-starter-active-directory-b2c;3.0.0-beta.1;3.0
com.azure.spring:azure-spring-boot-starter-active-directory;3.0.0-beta.1;3.0.0-beta.1
com.azure.spring:azure-spring-boot-starter-cosmos;3.0.0-beta.1;3.0.0-beta.1
com.azure.spring:azure-spring-boot-starter-data-gremlin;3.0.0-beta.1;3.0.0-beta.1
com.azure.spring:azure-spring-boot-starter-keyvault-certificates;3.0.0-beta.1;3.0.0-beta.1
com.azure.spring:azure-spring-boot-starter-keyvault-secrets;3.0.0-beta.1;3.0.0-beta.1
com.azure.spring:azure-spring-boot-starter-metrics;3.0.0-beta.1;3.0.0-beta.1
com.azure.spring:azure-spring-boot-starter-servicebus-jms;3.0.0-beta.1;3.0.0-beta.1
Expand Down
4 changes: 4 additions & 0 deletions sdk/keyvault/azure-security-keyvault-jca/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Release History

## 1.0.0-beta.1 (Unreleased)
mnriem marked this conversation as resolved.
Show resolved Hide resolved

127 changes: 127 additions & 0 deletions sdk/keyvault/azure-security-keyvault-jca/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# JCA Provider for Azure Key Vault

The JCA Provider for Azure Key Vault is a JCA provider for certificates in
Azure Key Vault. It is built on four principles:

1. Must be extremely thin to run within a JVM
1. Must not introduce any library version conflicts with Java app code dependencies
1. Must not introduce any class loader hierarchy conflicts with Java app code dependencies
mnriem marked this conversation as resolved.
Show resolved Hide resolved
1. Must be ready for "never trust, always verify and credential-free" Zero Trust environments.

## Testing the version under development
mnriem marked this conversation as resolved.
Show resolved Hide resolved

If you want to test the current version under development you will have to
build and install it into your local Maven repository. To do so use the
following command line:

```
mvn clean install -DskipTests=true
```

## Server side SSL

If you are looking to integrate the JCA provider to create a SSLServerSocket
mnriem marked this conversation as resolved.
Show resolved Hide resolved
see the example below.

```java
KeyVaultJcaProvider provider = new KeyVaultJcaProvider();
Security.addProvider(provider);

KeyStore ks = KeyStore.getInstance("AzureKeyVault");
KeyVaultLoadStoreParameter parameter = new KeyVaultLoadStoreParameter(
System.getProperty("azure.keyvault.uri"),
System.getProperty("azure.tenant.id"),
System.getProperty("azure.client.id"),
System.getProperty("azure.client.secret"));
ks.load(parameter);

KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, "".toCharArray());

SSLContext context = SSLContext.getInstance("TLS");
context.init(kmf.getKeyManagers(), null, null);

SSLServerSocketFactory factory = (SSLServerSocketFactory) context.getServerSocketFactory();
SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(8765);
```

Note if you want to use Azure managed identity, you should set the value
of `azure.keyvault.uri`, and the rest of the parameters would be `null`.

## Client side SSL

If you are looking to integrate the JCA provider for client side socket
connections, see the Apache HTTP client example below.

```java
KeyVaultJcaProvider provider = new KeyVaultJcaProvider();
Security.addProvider(provider);

KeyStore ks = KeyStore.getInstance("AzureKeyVault");
KeyVaultLoadStoreParameter parameter = new KeyVaultLoadStoreParameter(
System.getProperty("azure.keyvault.uri"),
System.getProperty("azure.tenant.id"),
System.getProperty("azure.client.id"),
System.getProperty("azure.client.secret"));
ks.load(parameter);

SSLContext sslContext = SSLContexts
.custom()
.loadTrustMaterial(ks, new TrustSelfSignedStrategy())
.build();

SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder
.create()
.setSslContext(sslContext)
.setHostnameVerifier((hostname, session) -> {
return true;
})
.build();

PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder
.create()
.setSSLSocketFactory(sslSocketFactory)
.build();

String result = null;

try ( CloseableHttpClient client = HttpClients.custom().setConnectionManager(cm).build()) {
HttpGet httpGet = new HttpGet("https://localhost:8766");
HttpClientResponseHandler<String> responseHandler = (ClassicHttpResponse response) -> {
int status = response.getCode();
String result1 = "Not success";
if (status == 204) {
result1 = "Success";
}
return result1;
};
result = client.execute(httpGet, responseHandler);
} catch (IOException ioe) {
ioe.printStackTrace();
}
Comment on lines +57 to +101
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; Small details.

Suggested change
KeyVaultJcaProvider provider = new KeyVaultJcaProvider();
Security.addProvider(provider);
KeyStore ks = KeyStore.getInstance("AzureKeyVault");
KeyVaultLoadStoreParameter parameter = new KeyVaultLoadStoreParameter(
System.getProperty("azure.keyvault.uri"),
System.getProperty("azure.tenant.id"),
System.getProperty("azure.client.id"),
System.getProperty("azure.client.secret"));
ks.load(parameter);
SSLContext sslContext = SSLContexts
.custom()
.loadTrustMaterial(ks, new TrustSelfSignedStrategy())
.build();
SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder
.create()
.setSslContext(sslContext)
.setHostnameVerifier((hostname, session) -> {
return true;
})
.build();
PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder
.create()
.setSSLSocketFactory(sslSocketFactory)
.build();
String result = null;
try ( CloseableHttpClient client = HttpClients.custom().setConnectionManager(cm).build()) {
HttpGet httpGet = new HttpGet("https://localhost:8766");
HttpClientResponseHandler<String> responseHandler = (ClassicHttpResponse response) -> {
int status = response.getCode();
String result1 = "Not success";
if (status == 204) {
result1 = "Success";
}
return result1;
};
result = client.execute(httpGet, responseHandler);
} catch (IOException ioe) {
ioe.printStackTrace();
}
KeyVaultJcaProvider provider = new KeyVaultJcaProvider();
Security.addProvider(provider);
KeyStore ks = KeyStore.getInstance("AzureKeyVault");
KeyVaultLoadStoreParameter parameter = new KeyVaultLoadStoreParameter(
System.getProperty("azure.keyvault.uri"),
System.getProperty("azure.tenant.id"),
System.getProperty("azure.client.id"),
System.getProperty("azure.client.secret"));
ks.load(parameter);
SSLContext sslContext = SSLContexts
.custom()
.loadTrustMaterial(ks, new TrustSelfSignedStrategy())
.build();
SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder
.create()
.setSslContext(sslContext)
.setHostnameVerifier((hostname, session) -> {
return true;
})
.build();
PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder
.create()
.setSSLSocketFactory(sslSocketFactory)
.build();
String result = null;
try (CloseableHttpClient client = HttpClients.custom().setConnectionManager(cm).build()) {
HttpGet httpGet = new HttpGet("https://localhost:8766");
HttpClientResponseHandler<String> responseHandler = (ClassicHttpResponse response) -> {
int status = response.getCode();
String result1 = "Not success";
if (status == 204) {
result1 = "Success";
}
return result1;
};
result = client.execute(httpGet, responseHandler);
} catch (IOException ioe) {
ioe.printStackTrace();
}

```

Note if you want to use Azure managed identity, you should set the value
mnriem marked this conversation as resolved.
Show resolved Hide resolved
of `azure.keyvault.uri`, and the rest of the parameters would be `null`.

## Spring Boot

For Spring Boot applications see our [Spring Boot starter]<!--(../../spring/azure-spring-boot-starter-keyvault-certificates/README.md)-->.
mnriem marked this conversation as resolved.
Show resolved Hide resolved

## Reference

1. [Java Cryptography Architecture (JCA) Reference Guide](https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html)

# Azure KeyVault JCA client library for Java

# Getting started

# Key concepts

# Examples

# Troubleshooting

# Next steps

# Contributing
mnriem marked this conversation as resolved.
Show resolved Hide resolved
Loading