You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.Set environment variables created in `azure-spring-boot-sample-keyvault-certificates-server-side` application by running command:
24
+
1.Option 1 - If you created the resources via the script, you need set environment variables created in `azure-spring-boot-sample-keyvault-certificates-server-side` application by running command:
25
25
```
26
26
source script/setup.sh
27
27
```
28
-
#### Using TLS with service principal
28
+
2. Option 2 - If you created the resource via the Azure Portal, you need configure the application.yml manually, please replace the placeholders with the resources you created.
29
+
#### Using TLS with service principal created via App registration.
29
30
1. Start azure-spring-boot-sample-keyvault-certificates-client-side's SampleApplication by running command:
30
31
```
31
32
mvn spring-boot:run
@@ -37,7 +38,7 @@ This sample should work together with [azure-spring-boot-sample-keyvault-certifi
37
38
Response from "https://localhost:8443/": Hello World
38
39
```
39
40
40
-
#### Using mTLS with service principal
41
+
#### Using mTLS with service principal created via App registration.
41
42
1. In the sample `ApplicationConfiguration.class`, change the `self-signed` to your certificate alias.
@@ -134,6 +135,19 @@ This sample should work together with [azure-spring-boot-sample-keyvault-certifi
134
135
```
135
136
1. Follow the above step of [Using mTLS with service principal](#using-mtls-with-service-principal).
136
137
138
+
139
+
### (Optional) Use the KeyVaultKeyStore with local certificates as the trust resources.
140
+
- For example, there are some well known CAs. You can put them into a folder, then configure in the application.yml the azure:cert-path:well-known=\<yourFolderPath>. The certificates in this folder will be loaded by KeyVaultKeystore. If you don't configure such a property, the default well-known path will be `/etc/certs/well-known/`.
141
+
- Besides the well-known path, you can also put your customized certificates into another folder specified by azure:cert-path:custom=\<yourCustomPath>, by default, the custom path is `/etc/certs/custom/`.
142
+
- You can also put certificates under the class path, build a folder named `keyvault` and configure it under the class path, then all the certificates in this folder will be loaded by key vault keystore.
143
+
144
+
To configure the local certificates, please uncomment and configure the optional local certificates path.
145
+
```yaml
146
+
azure:
147
+
#cert-path:
148
+
#well-known: # Optional local certificates path. Your local path that holds the well-known certificates.
149
+
#custom: # Optional local certificates path. Your local path that holds your customized certificates.
Copy file name to clipboardExpand all lines: keyvault/azure-spring-boot-starter-keyvault-certificates/keyvault-certificates-client-side/src/main/resources/application.yml
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,5 +6,8 @@ azure:
6
6
client-secret: ${SERVICE_PRINCIPAL_SECRET} # The Client Secret that will be used for accessing your Azure Key Vault (needed if you are not using managed identity).
7
7
# managed-identity: # client-id of the user-assigned managed identity to use.
8
8
# If the above 4 properties are empty, then system-assigned managed identity will be used.
9
+
#cert-path:
10
+
#well-known: # Optional local certificates path. Your local path that holds the well-known certificates.
11
+
#custom: # Optional local certificates path. Your local path that holds your customized certificates.
Copy file name to clipboardExpand all lines: keyvault/azure-spring-boot-starter-keyvault-certificates/keyvault-certificates-server-side/README.md
+38-6Lines changed: 38 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,8 @@ This sample can work together with [azure-spring-boot-sample-keyvault-certificat
24
24
- This sample will create and store a certificate in your Azure Key Vault.
25
25
- This sample will create a service principal to read certificates/keys/secrets from your Azure Key Vault.
26
26
27
-
### Run Sample with service principal
27
+
### Create resources: Service Principal and Key Vault.
28
+
#### Option 1 - via the script
28
29
1. Run command `az login` to login to the Azure CLI.
29
30
1. Open `scripts/export_environment_variables.sh` and enter the following information:
30
31
```
@@ -50,7 +51,18 @@ This sample can work together with [azure-spring-boot-sample-keyvault-certificat
50
51
```
51
52
source script/setup.sh
52
53
```
53
-
#### Using TLS with service principal
54
+
55
+
#### Option 2 - via Azure Portal
56
+
You can also create resources manually via Azure Portal. Please follow:
57
+
1. Obtain a Service Principal. There are two ways to obtain a service principal:
58
+
- Recommended: enable a managed identity for the application. For more information, see [the Managed identity overview][the_managed_identity_overview].
59
+
- If you cannot use managed identity, you can register your application with AAD, see [register app with AAD][register_app_with_AAD]. The registration also creates a second application object that identifies your app.
60
+
2. Create the key vault and certificates. Please refer to [create key vault and certificates][create_key_vault_and_certificates]
61
+
3. Make the key vault accessible to your service principal. Please refer to [assign key vault access policy][assign_key_vault_access_policy]
62
+
4. You need manually configure the application.yml, replace the placeholders with the resources you created in the Azure Portal.
63
+
64
+
If you used the script to create the resources, or you created the resources via Azure Portal and created the Service Principal in App Registration way.
65
+
### Run sample Using TLS.
54
66
1. Run command `mvn spring-boot:run`
55
67
1. Access https://localhost:8443/
56
68
@@ -59,23 +71,26 @@ Then you will get
59
71
Hello World
60
72
```
61
73
62
-
#### Using mTLS with service principal
74
+
###Run sample Using mTLS
63
75
64
76
1. Add properties in application.yml on the base of current configuration:
65
77
```yaml
66
78
server:
67
79
ssl:
68
80
client-auth: need # Used for mTLS
69
81
trust-store-type: AzureKeyVault # Used for mTLS
82
+
70
83
```
71
-
2. Run command `mvn spring-boot:run`
72
-
1. mTLS for mutual authentication. So your client needs have a trusted CA certificate.([azure-spring-boot-sample-keyvault-certificates-client-side]is a trusted client sample.)
84
+
1. Run command `mvn spring-boot:run`
85
+
1. mTLS for mutual authentication. So your client needs to have a trusted CA certificate.([azure-spring-boot-sample-keyvault-certificates-client-side]is a trusted client sample.)
73
86
1. Your client access https://localhost:8443/
74
87
75
88
Then the client or server will get
76
89
```text
77
90
Hello World
78
91
```
92
+
93
+
If you created resources via Azure Portal and created the Service Principal in Managed Identity way.
79
94
### Run Sample with managed identity
80
95
If you are using managed identity instead of service principal, use below properties in your `application.yml`:
81
96
@@ -86,7 +101,7 @@ azure:
86
101
# managed-identity: # client-id of the user-assigned managed identity to use. If empty, then system-assigned managed identity will be used.
87
102
server:
88
103
ssl:
89
-
key-alias: self-signed
104
+
key-alias: ${CERTIFICATE_NAME}
90
105
key-store-type: AzureKeyVault
91
106
```
92
107
Make sure the managed identity can access target Key Vault.
@@ -113,6 +128,19 @@ Make sure the managed identity can access target Key Vault.
113
128
114
129
1. Follow the above step of [Using TLS with service principal](#using-tls-with-service-principal) or [Using mTLS with service principal](#using-mtls-with-service-principal).
115
130
131
+
132
+
### (Optional) Use the KeyVaultKeyStore with local certificates as the trust resources. This is only useful when server needs to trust its party, for example when the server opens mTLS mode.
133
+
- For example, there are some well known CAs. You can put them into a folder, then configure in the application.yml the azure:cert-path:well-known=\<yourFolderPath>. The certificates in this folder will be loaded by KeyVaultKeystore. If you don't configure such a property, the default well-known path will be `/etc/certs/well-known/`.
134
+
- Besides the well-known path, you can also put your customized certificates into another folder specified by azure:cert-path:custom=\<yourCustomPath>, by default, the custom path is `/etc/certs/custom/`.
135
+
- You can also put certificates under the class path, build a folder named `keyvault` and configure it under the class path, then all the certificates in this folder will be loaded by key vault keystore.
136
+
137
+
To configure the local certificates, please uncomment and configure the optional local certificates path.
138
+
```yaml
139
+
azure:
140
+
#cert-path:
141
+
#well-known: # Optional local certificates path. Your local path that holds the well-known certificates.
142
+
#custom: # Optional local certificates path. Your local path that holds your customized certificates.
143
+
```
116
144
## Examples
117
145
## Troubleshooting
118
146
## Next steps
@@ -124,3 +152,7 @@ Make sure the managed identity can access target Key Vault.
Copy file name to clipboardExpand all lines: keyvault/azure-spring-boot-starter-keyvault-certificates/keyvault-certificates-server-side/src/main/resources/application.yml
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ azure:
6
6
client-secret: ${SERVICE_PRINCIPAL_SECRET} # The Client Secret that will be used for accessing your Azure Key Vault (needed if you are not using managed identity).
7
7
# managed-identity: # The user-assigned managed identity client-id to use.
8
8
# If the above 4 properties are empty, then system-assigned managed identity will be used.
9
+
#cert-path:
10
+
#well-known: # Optional local certificates path. Your local path that holds the well-known certificates.
11
+
#custom: # Optional local certificates path. Your local path that holds your customized certificates.
0 commit comments