简体   繁体   中英

how to retrieve secrets from azure vault using java 5?

I have to retrieve secrets from Azure Vault but my app uses jdk 5. This is a problem because the azure libraries used and described in Microsoft docs require at minimum jdk 8 and upgrading the jdk is not an option.

The client's architect says that I can consume some vault api and use bouncy castle's tls api to achieve this but I'm not sure what is he talking about.

This sounds too low level. I'm asking for guidance, some superfluous explanation can get me going. How can I obtain secrets using Java 5?

As the architect says, you could retrieve a secret from Key Vault by Key Vault REST API instead of azure libraries.

GET https://{yourvault}.vault.azure.net/secrets?api-version=7.1

This API is used to list secrets in a specified key vault. And you could get a specified secret from a given key vault by this link .


First, get access_token with Post viaApacheHttpClient .

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

client_id={your-client-id}
&scope=https%3A%2F%2Fvault.azure.net%2F.default
&client_secret={your-client-secret}
&grant_type=client_credentials

Then, call the REST API with Get viaApacheHttpClient .

GET https://{yourvault}.vault.azure.net/secrets?api-version=7.1
Authorization: Bearer {access_token}

I try this with Postman, and it works well. You could use httpclient to obtain secrets by java.

在此处输入图片说明

Note:

Navigate to Azure Portal > Key vaults > your_key_vault > Access policies > Add Access Policy. In secret permissions field, select desired permissions and Select Principal section, select the application that you are using to access the secret.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM