Configure a JKS store and use Postman to test requests

vk1
Occasional Visitor

Configure a JKS store and use Postman to test requests

We recently got production access to Visa Developer Program. I was able to configure Two Way SSL  for the sandbox environment  and was able to successfully call the APIs and also use Postman.

 

I created the CSR file for Production using the following commands

 

keytool -genkeypair -alias client -keyalg RSA -keysize 2048 -keystore merchantSearch_keyAndCertBundle_prod.jks -storepass  xxx -keypass xxx -dname "CN=visa.abc.com, OU=Engineering, O=ABC , L=San Jose, ST=California, C=US, UID=UID-PROD"

 

Created CSR using the following command

keytool -certreq -alias client -keystore merchantSearch_keyAndCertBundle_prod.jks -storepass xxx -keypass xxx -file merchantSearch_keyAndCertBundle_prod.csr

 

The CSR file was uploaded and approved by visa and Credentials was created for production access. The Certificate was generated in a .pem format. Postman expects a .crt file and the corresponding key file and a passphrase. Where do i get that information.

 

i also issued the following commands:

 

keytool -import -alias servicesroot -keystore merchantSearch_keyAndCertBundle_prod.jks -file VisaServicesCARoot.pem -storepass xxx

keytool -import -alias servicesinter -keystore merchantSearch_keyAndCertBundle_prod.jks -file VisaServicesCAInter.pem -storepass xxx

keytool -import -alias digicert -keystore merchantSearch_keyAndCertBundle_prod.jks -file DigiCertGlobalRootCA_visa_prod.crt -storepass xxx

 

For sandbox the self signing csr created a key in the .pem format which i used in Postman and i was able to execute requests. Also programmatically i was able to access the Visa API through Spring Boot RestTemplate. For Production properties I get 401 unAuthorized

How do i access Visa APIs using postman

2 REPLIES 2
jenn_kh
Community Moderator

Re: Configure a JKS store and use Postman to test requests

Hi @vk1Thank you for reaching out. An agent will look into this and get back to you as soon as possible. In the meantime, if any community member knows a solution, feel free to reply in this thread. 

API_Products
Visa Developer Support Specialist

Re: Configure a JKS store and use Postman to test requests

Hey @vk1,

 

Since you mentioned production environment, you should reach out directly to Visa Developer Support at developer@visa.com to ask them to connect you with your assigned Implementation Manager or an API Specialist.

 

Below are troubleshooting tips in the meantime. To access Visa APIs using Postman in the production environment, follow these steps based on the Visa Developer Platform documentation:

 

1. Convert the .pem Certificate to .crt and Key Files:
- Since Postman expects a .crt file and a corresponding key file, you need to convert the .pem certificate you received from Visa into the required formats.
- Use the following OpenSSL commands to convert the .pem file to the necessary .crt and key files:
```
openssl x509 -outform der -in your_certificate.pem -out your_certificate.crt
openssl rsa -in your_certificate.pem -out your_private_key.key
```

 

2. Configure Postman with the .crt and Key Files:
- Open Postman and go to the settings (top-right corner).
- Navigate to the "Certificates" tab.
- Click on "Add Certificate".
- Enter the Visa API URL (e.g., https://api.visa.com).
- Upload the .crt file and the key file you generated using the OpenSSL commands.
- Enter the passphrase you used when generating the CSR, if required.

 

3. Import Visa CA Certificates:
- You have already imported the Visa CA certificates into your keystore using the keytool commands. Ensure these certificates are trusted in your environment.
- If you need to use these CA certificates in Postman, you can also add them under the "Certificates" tab in Postman settings.

 

4. Make API Requests in Postman:
- Create a new request in Postman.
- Set the request type (GET, POST, etc.) as required by the Visa API.
- Enter the production URL for the Visa API endpoint.
- In the Headers section of your request, add the necessary headers, including the Authorization header with your API key and secret.
- Example headers:
```
Authorization: Basic <Your Base64 Encoded API Key and Secret>
Content-Type: application/json
```

 

5. Troubleshooting 401 Unauthorized Error:
- Verify that the API key and secret you are using are correct and have the necessary permissions for the production environment.
- Ensure that the certificate and key files are correctly configured in Postman.
- Check the API documentation for any additional required headers or parameters.
- Ensure that the Visa CA certificates are trusted in your environment.

 

6. Spring Boot RestTemplate Configuration:
- If you are also using Spring Boot RestTemplate to access Visa APIs, ensure that the production properties are correctly configured.
- Configure the RestTemplate with the production key and certificate files.
- Example configuration:


```java
@Bean
public RestTemplate restTemplate() throws Exception {
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(new FileInputStream("merchantSearch_keyAndCertBundle_prod.jks"), "storepass".toCharArray());

SSLContext sslContext = SSLContexts.custom()
.loadKeyMaterial(keyStore, "keypass".toCharArray())
.loadTrustMaterial(new File("VisaServicesCARoot.pem"), new TrustSelfSignedStrategy())
.build();

HttpClient httpClient = HttpClients.custom()
.setSslcontext(sslContext)
.build();

HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
return new RestTemplate(factory);
}
```

 

By following these steps, you should be able to access Visa APIs using Postman and resolve the 401 Unauthorized error for production properties. 




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.