Now let’s move to the next step to understand how to consume the above API from another spring boot application using REST Template STEP3: Place the keystore in resources folder: It will then add it to the list of trusted certificates: You need to click on Advanced button and ask the browser to trust this certificate. This is because the browser doesn’t know the certificate you created. Now when you try to access this API in the browser you get this: The API is now protected with SSL and runs on port 8443 as most https applications run so. Key-store: classpath:mydemocertificate.p12 This is a sample spring boot application created with a simple REST API: To do this, just place the keystore you created using the above steps in the resources folder of the application you want to protect: The keystore is now ready with the certificate I created!Īs already mentioned you can import any certificate directly into the keystore instead of creating a new key pair.īefore consuming a secured REST API, let’s see how to create a secured REST API first using the above keystore. p12 extension after giving a password for the keystore just like you gave for keypair: You need to do this to add your domain and ip address in case if you are testing from your local machineĬhoose extension type as Subject Alternative Name: You can import the certificates you downloaded directly into a new keystore instead ,as well.Ĭlick on Add Extensions. Here I am creating my own certificate and then adding it to a new keystore. Just create a keystore with the certificates you downloaded. You can do this using a tool like KeyStoreExplorer : You can download the certificates from any popular browser. ![]() How to call REST API protected with SSL (https) from Spring Boot ?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |