<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Not able to access APIC REST APIs with web token in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462772#M2445</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a simple REST Client using Spring boot, when I try to make first POST call to following service :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" title="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes"&gt;https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using following implementation :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import java.util.ArrayList;&lt;/P&gt;&lt;P&gt;import java.util.List;&lt;/P&gt;&lt;P&gt;import org.springframework.boot.CommandLineRunner;&lt;/P&gt;&lt;P&gt;import org.springframework.boot.SpringApplication;&lt;/P&gt;&lt;P&gt;import org.springframework.boot.autoconfigure.SpringBootApplication;&lt;/P&gt;&lt;P&gt;import org.springframework.http.HttpEntity;&lt;/P&gt;&lt;P&gt;import org.springframework.http.HttpHeaders;&lt;/P&gt;&lt;P&gt;import org.springframework.http.HttpMethod;&lt;/P&gt;&lt;P&gt;import org.springframework.http.MediaType;&lt;/P&gt;&lt;P&gt;import org.springframework.http.ResponseEntity;&lt;/P&gt;&lt;P&gt;import org.springframework.web.client.HttpClientErrorException;&lt;/P&gt;&lt;P&gt;import org.springframework.web.client.RestTemplate;&lt;/P&gt;&lt;P&gt;import com.fasterxml.jackson.core.JsonFactory;&lt;/P&gt;&lt;P&gt;import com.fasterxml.jackson.core.JsonParser;&lt;/P&gt;&lt;P&gt;import com.fasterxml.jackson.core.JsonToken;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@SpringBootApplication&lt;/P&gt;&lt;P&gt;public class RestApplication implements CommandLineRunner {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; String jsonStringUser = "{" + "\"aaaUser\":" + "{" + "\"attributes\":" + "{" + "\"name\":\"user\"" + ","&lt;/P&gt;&lt;P&gt;&amp;nbsp; + "\"pwd\":\"password\"" + "} } }";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; public static void main(String args[]) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; SpringApplication.run(RestApplication.class);&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; @Override&lt;/P&gt;&lt;P&gt;&amp;nbsp; public void run(String... args) throws Exception {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RestTemplate restTemplate = new RestTemplate();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; String urlToken = "";&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpHeaders header = new HttpHeaders();&lt;/P&gt;&lt;P&gt;&amp;nbsp; header.setContentType(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; List&amp;lt;MediaType&amp;gt; aList = new ArrayList&amp;lt;MediaType&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp; aList.add(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; header.setAccept(aList);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpEntity&amp;lt;String&amp;gt; entity = new HttpEntity&amp;lt;String&amp;gt;(jsonStringUser, header);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; try {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ResponseEntity&amp;lt;String&amp;gt; result = restTemplate.exchange(&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" rel="nofollow" target="_blank"&gt;http://192.168.1.145/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;SPAN&gt;", HttpMethod.POST, entity,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; String.class);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; JsonFactory factory = new JsonFactory();&lt;/P&gt;&lt;P&gt;&amp;nbsp; JsonParser parser = factory.createParser(result.getBody().toString());&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while (!parser.isClosed()) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; JsonToken jsonToken = parser.nextToken();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (JsonToken.VALUE_STRING.equals(jsonToken)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; String fieldName = (String) parser.getCurrentName();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (fieldName.equals("urlToken")) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;urlToken&lt;/STRONG&gt; = parser.getValueAsString();&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Value :&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " + urlToken);&lt;/P&gt;&lt;P&gt;&amp;nbsp; break;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; catch (HttpClientErrorException ex) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Exception is " + ex.getMessage());&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Exception is " + ex.getResponseBodyAsString());&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Exception is " + ex.getMostSpecificCause());&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It failed throwing following exception :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;java.lang.IllegalStateException: Failed to execute CommandLineRunner&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at borderlessodc.api.Application.main(Application.java:135) [main/:na]&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" rel="nofollow" target="_blank"&gt;https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;SPAN&gt;": java.security.cert.CertificateException: No subject alternative names present; nested exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at borderlessodc.api.Application.run(Application.java:200) [main/:na]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) [spri-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; ... 6 common frames omitted&lt;/P&gt;&lt;P&gt;Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:80) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.2.7.RELEASE.jar:4.2.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:596) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; ... 10 common frames omitted&lt;/P&gt;&lt;P&gt;Caused by: &lt;STRONG&gt;java.security.cert.CertificateException: No subject alternative names present&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:144) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.util.HostnameChecker.match(HostnameChecker.java:93) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; ... 24 common frames omitted&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To overcome above mentioned error I have added this code before the first call to the REST :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(&lt;/P&gt;&lt;P&gt;&amp;nbsp; new javax.net.ssl.HostnameVerifier(){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean verify(String hostname,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; javax.net.ssl.SSLSession sslSession) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return hostname.equals("192.168.1.145");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then my first REST call completed with expected response and I am able to extract the urlToken from it which I again passed to subsequent REST call as "APIC-challenger" header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RestTemplate restTemplate1 = new RestTemplate();&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpHeaders header1 = new HttpHeaders();&lt;/P&gt;&lt;P&gt;&amp;nbsp; header.setContentType(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; List&amp;lt;MediaType&amp;gt; aList1 = new ArrayList&amp;lt;MediaType&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp; aList1.add(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; header1.setAccept(aList1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; header1.set("APIC-challenge", &lt;STRONG&gt;urlToken&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpEntity&amp;lt;String&amp;gt; entity1 = new HttpEntity&amp;lt;String&amp;gt;(header1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Second Entity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " + entity1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; ResponseEntity&amp;lt;String&amp;gt; result1 = restTemplate1.exchange("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://192.168.1.145/api/class/topSystem.json" rel="nofollow" target="_blank"&gt;https://192.168.1.145/api/class/topSystem.json&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpMethod.GET, entity1, String.class);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now making this subsequent call I am getting following response :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{"imdata":[{"error":{"attributes":{"code":"&lt;STRONG&gt;403&lt;/STRONG&gt;","text":"&lt;STRONG&gt;Need a valid webtoken cookie&lt;/STRONG&gt; (named APIC-Cookie) or a signed request with signature in the cookie APIC-Request-Signature for all REST API requests"}}}]}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried passing &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;APIC-Cookie &lt;/STRONG&gt;header with the value received from first POST response header but response remains the same.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can security imposed by APIC be bypassed i.e. is there any way to turn of this security from APIC web GUI and accordingly later on roll back?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jul 2016 03:56:07 GMT</pubDate>
    <dc:creator>abhishek.abhi</dc:creator>
    <dc:date>2016-07-26T03:56:07Z</dc:date>
    <item>
      <title>Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462769#M2442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I have written a Simple Java REST client using Spring boot framework and tried to access APIs exposed by APIC. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I am able to get proper response from POST request : &lt;/P&gt;&lt;P&gt;POST : &lt;A href="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" title="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes"&gt;https://[apic ip]/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;payload &lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"aaaUser" : {&lt;/P&gt;&lt;P&gt;"attributes" : {&lt;/P&gt;&lt;P&gt;"name" : "username",&lt;/P&gt;&lt;P&gt;"pwd" : "password"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. To make subsequent REST request I have used url token provide by above REST response as header with name 'APIC-challenge'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET : &lt;A href="https://192.168.1.145/api/class/topSystem.json" title="https://192.168.1.145/api/class/topSystem.json"&gt;https://[apic-ip]/api/class/topSystem.json&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got following response : Response code : 403&lt;/P&gt;&lt;P&gt;"text":"Need a valid webtoken cookie (named APIC-Cookie) or a signed request with signature in the cookie APIC-Request-Signature for all REST API requests"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly suggest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2016 07:08:53 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462769#M2442</guid>
      <dc:creator>abhishek.abhi</dc:creator>
      <dc:date>2016-07-25T07:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462770#M2443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, if REST request made by browser clients like POSTMAN required results are observed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2016 07:15:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462770#M2443</guid>
      <dc:creator>abhishek.abhi</dc:creator>
      <dc:date>2016-07-25T07:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462771#M2444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it worked in POSTMAN, then it should have worked in Java.&amp;nbsp; From this, it looks like cookies may be blocked in your Java app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that's not the case, then could you send us your Java code so we can have a look, and try it here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2016 01:24:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462771#M2444</guid>
      <dc:creator>davbark2</dc:creator>
      <dc:date>2016-07-26T01:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462772#M2445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a simple REST Client using Spring boot, when I try to make first POST call to following service :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" title="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes"&gt;https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using following implementation :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import java.util.ArrayList;&lt;/P&gt;&lt;P&gt;import java.util.List;&lt;/P&gt;&lt;P&gt;import org.springframework.boot.CommandLineRunner;&lt;/P&gt;&lt;P&gt;import org.springframework.boot.SpringApplication;&lt;/P&gt;&lt;P&gt;import org.springframework.boot.autoconfigure.SpringBootApplication;&lt;/P&gt;&lt;P&gt;import org.springframework.http.HttpEntity;&lt;/P&gt;&lt;P&gt;import org.springframework.http.HttpHeaders;&lt;/P&gt;&lt;P&gt;import org.springframework.http.HttpMethod;&lt;/P&gt;&lt;P&gt;import org.springframework.http.MediaType;&lt;/P&gt;&lt;P&gt;import org.springframework.http.ResponseEntity;&lt;/P&gt;&lt;P&gt;import org.springframework.web.client.HttpClientErrorException;&lt;/P&gt;&lt;P&gt;import org.springframework.web.client.RestTemplate;&lt;/P&gt;&lt;P&gt;import com.fasterxml.jackson.core.JsonFactory;&lt;/P&gt;&lt;P&gt;import com.fasterxml.jackson.core.JsonParser;&lt;/P&gt;&lt;P&gt;import com.fasterxml.jackson.core.JsonToken;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@SpringBootApplication&lt;/P&gt;&lt;P&gt;public class RestApplication implements CommandLineRunner {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; String jsonStringUser = "{" + "\"aaaUser\":" + "{" + "\"attributes\":" + "{" + "\"name\":\"user\"" + ","&lt;/P&gt;&lt;P&gt;&amp;nbsp; + "\"pwd\":\"password\"" + "} } }";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; public static void main(String args[]) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; SpringApplication.run(RestApplication.class);&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; @Override&lt;/P&gt;&lt;P&gt;&amp;nbsp; public void run(String... args) throws Exception {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; RestTemplate restTemplate = new RestTemplate();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; String urlToken = "";&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpHeaders header = new HttpHeaders();&lt;/P&gt;&lt;P&gt;&amp;nbsp; header.setContentType(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; List&amp;lt;MediaType&amp;gt; aList = new ArrayList&amp;lt;MediaType&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp; aList.add(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; header.setAccept(aList);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpEntity&amp;lt;String&amp;gt; entity = new HttpEntity&amp;lt;String&amp;gt;(jsonStringUser, header);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; try {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ResponseEntity&amp;lt;String&amp;gt; result = restTemplate.exchange(&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" rel="nofollow" target="_blank"&gt;http://192.168.1.145/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;SPAN&gt;", HttpMethod.POST, entity,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; String.class);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; JsonFactory factory = new JsonFactory();&lt;/P&gt;&lt;P&gt;&amp;nbsp; JsonParser parser = factory.createParser(result.getBody().toString());&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while (!parser.isClosed()) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; JsonToken jsonToken = parser.nextToken();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (JsonToken.VALUE_STRING.equals(jsonToken)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; String fieldName = (String) parser.getCurrentName();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (fieldName.equals("urlToken")) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;urlToken&lt;/STRONG&gt; = parser.getValueAsString();&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Value :&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " + urlToken);&lt;/P&gt;&lt;P&gt;&amp;nbsp; break;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; catch (HttpClientErrorException ex) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Exception is " + ex.getMessage());&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Exception is " + ex.getResponseBodyAsString());&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Exception is " + ex.getMostSpecificCause());&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It failed throwing following exception :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;java.lang.IllegalStateException: Failed to execute CommandLineRunner&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at borderlessodc.api.Application.main(Application.java:135) [main/:na]&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes" rel="nofollow" target="_blank"&gt;https://192.168.1.145/api/aaaLogin.json?gui-token-request=yes&lt;/A&gt;&lt;SPAN&gt;": java.security.cert.CertificateException: No subject alternative names present; nested exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at borderlessodc.api.Application.run(Application.java:200) [main/:na]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) [spri-1.3.6.RELEASE.jar:1.3.6.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; ... 6 common frames omitted&lt;/P&gt;&lt;P&gt;Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:80) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.2.7.RELEASE.jar:4.2.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:596) ~[spring-web-4.2.7.RELEASE.jar:4.2.7.RELEASE]&lt;/P&gt;&lt;P&gt;&amp;nbsp; ... 10 common frames omitted&lt;/P&gt;&lt;P&gt;Caused by: &lt;STRONG&gt;java.security.cert.CertificateException: No subject alternative names present&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:144) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.util.HostnameChecker.match(HostnameChecker.java:93) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) ~[na:1.8.0_91]&lt;/P&gt;&lt;P&gt;&amp;nbsp; ... 24 common frames omitted&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To overcome above mentioned error I have added this code before the first call to the REST :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(&lt;/P&gt;&lt;P&gt;&amp;nbsp; new javax.net.ssl.HostnameVerifier(){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean verify(String hostname,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; javax.net.ssl.SSLSession sslSession) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return hostname.equals("192.168.1.145");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then my first REST call completed with expected response and I am able to extract the urlToken from it which I again passed to subsequent REST call as "APIC-challenger" header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RestTemplate restTemplate1 = new RestTemplate();&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpHeaders header1 = new HttpHeaders();&lt;/P&gt;&lt;P&gt;&amp;nbsp; header.setContentType(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; List&amp;lt;MediaType&amp;gt; aList1 = new ArrayList&amp;lt;MediaType&amp;gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp; aList1.add(MediaType.APPLICATION_JSON);&lt;/P&gt;&lt;P&gt;&amp;nbsp; header1.setAccept(aList1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; header1.set("APIC-challenge", &lt;STRONG&gt;urlToken&lt;/STRONG&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpEntity&amp;lt;String&amp;gt; entity1 = new HttpEntity&amp;lt;String&amp;gt;(header1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; System.out.println("Second Entity&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " + entity1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; ResponseEntity&amp;lt;String&amp;gt; result1 = restTemplate1.exchange("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://192.168.1.145/api/class/topSystem.json" rel="nofollow" target="_blank"&gt;https://192.168.1.145/api/class/topSystem.json&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HttpMethod.GET, entity1, String.class);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now making this subsequent call I am getting following response :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{"imdata":[{"error":{"attributes":{"code":"&lt;STRONG&gt;403&lt;/STRONG&gt;","text":"&lt;STRONG&gt;Need a valid webtoken cookie&lt;/STRONG&gt; (named APIC-Cookie) or a signed request with signature in the cookie APIC-Request-Signature for all REST API requests"}}}]}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried passing &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;APIC-Cookie &lt;/STRONG&gt;header with the value received from first POST response header but response remains the same.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can security imposed by APIC be bypassed i.e. is there any way to turn of this security from APIC web GUI and accordingly later on roll back?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Abhishek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2016 03:56:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462772#M2445</guid>
      <dc:creator>abhishek.abhi</dc:creator>
      <dc:date>2016-07-26T03:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462773#M2446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Customer replied later, and apparently it didn't make it into this thread:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="background: white none repeat scroll 0% 0%; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 7.5pt 0 15.0pt 0;"&gt; &lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #666666;"&gt;I have added following header to second REST request :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #666666;"&gt;header1.add("Cookie", "APIC-Cookie="+apicCookie);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #666666;"&gt;And I am getting 200 Ok result and hence my issue has been resolved. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #666666;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #666666;"&gt;Abhishek&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="background: whitesmoke none repeat scroll 0% 0%; padding: 7.5pt; width: 100%;"&gt;&lt;TBODY&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2016 18:39:39 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462773#M2446</guid>
      <dc:creator>davbark2</dc:creator>
      <dc:date>2016-07-26T18:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462774#M2447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone know where this header is added if using Postman?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 May 2018 23:45:34 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3462774#M2447</guid>
      <dc:creator>Devavrat Oka</dc:creator>
      <dc:date>2018-05-21T23:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3822170#M2448</link>
      <description>&lt;P&gt;For anyone else having this issue in Postman (which does automatically handle cookies by default), make sure you are using an HTTPS:// URI. If you copied/pasted from API Inspector in the APIC, it uses HTTP which only works from within the interface. Outside requires HTTPS and will give this (above) error if trying with HTTP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Switch to HTTPS and it should work.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 15:37:01 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/3822170#M2448</guid>
      <dc:creator>Ryan Wolfe</dc:creator>
      <dc:date>2019-03-19T15:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/4042238#M2449</link>
      <description>&lt;P&gt;Where do I add this code&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;header1.add("Cookie", "APIC-Cookie="+apicCookie);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;in the login request?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 19:07:19 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/4042238#M2449</guid>
      <dc:creator>John Standley</dc:creator>
      <dc:date>2020-03-07T19:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to access APIC REST APIs with web token</title>
      <link>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/4045248#M2450</link>
      <description>&lt;P&gt;For all of you who make API calls with Ansible URI module, this is what you need to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    - name: Login
      uri:
        url: "https://&amp;lt;IPADDRESS&amp;gt;/api/aaaLogin.json"
        method: POST
        headers:
          Content-Type: application/json
        body_format: json
        body:
          {
           "aaaUser":{
             "attributes":{
               "name": "&amp;lt;USER&amp;gt;",
               "pwd": "&amp;lt;PASSWORD&amp;gt;"
                          }
                     }
          }
        return_content: yes
        validate_certs: no
      register: output

This will return a token so that you can make any API call without using any password and username, for instance:

Getting the local users via API call using the token we just got from the API call above:

    - name: Create Token
      set_fact:
        aci_token: "{{ output['cookies_string'] }}"

    - uri:
        url: "https://&amp;lt;IPADDRESS&amp;gt;/api/class/aaaUser.json"
        method: GET
        headers:
          Content-Type: application/json
          Cookie: "{{ aci_token }}"
        return_content: yes
        validate_certs: no
      register: local_user

    - debug: var=local_user&lt;/PRE&gt;&lt;P&gt;Hope it helps !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ernesto Quintana&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 21:52:15 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/not-able-to-access-apic-rest-apis-with-web-token/m-p/4045248#M2450</guid>
      <dc:creator>ErnestoQJ</dc:creator>
      <dc:date>2020-03-12T21:52:15Z</dc:date>
    </item>
  </channel>
</rss>

