<?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 Have a Exception in java After importing the certificate in Network Security</title>
    <link>https://community.cisco.com/t5/network-security/have-a-exception-in-java-after-importing-the-certificate/m-p/4422333#M1081718</link>
    <description>&lt;P&gt;I imported the certificate to java trusted certificates, it shows the some error.is it due to certificate is Self-signed ?.&lt;/P&gt;&lt;P&gt;And is there any way to overcome this problem other than overriding SSL certificate verification.&lt;/P&gt;&lt;P&gt;Is there any way to add SAN to the certificate&lt;/P&gt;&lt;P&gt;I have searched in some website but it shows it is due to the Hostname or common name mismatch but can you tell me how to rectify it&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;this is the program used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;package A;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;import javax.net.ssl.HostnameVerifier;&lt;BR /&gt;import javax.net.ssl.HttpsURLConnection;&lt;BR /&gt;import javax.net.ssl.SSLSession;&lt;BR /&gt;import java.io.BufferedReader;&lt;BR /&gt;import java.io.IOException;&lt;BR /&gt;import java.io.InputStreamReader;&lt;BR /&gt;import java.io.OutputStream;&lt;BR /&gt;import java.net.URL;&lt;BR /&gt;import java.util.regex.Matcher;&lt;BR /&gt;import java.util.regex.Pattern;&lt;/P&gt;&lt;P&gt;public class Main {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;public static void main(String[] args) throws IOException {&lt;BR /&gt;System.out.println(System.getProperty("java.home"));&lt;BR /&gt;String https_url = "&lt;A href="https://10.1.60.60/api/fdm/latest/fdm/token" target="_blank"&gt;https://10.1.60.60/api/fdm/latest/fdm/token&lt;/A&gt;";&lt;BR /&gt;String jsonInputString = "{\"grant_type\": \"password\", \"username\": \"admin\", \"password\": \"Ashok@188616\"}";&lt;BR /&gt;URL url = new URL(https_url);&lt;BR /&gt;HttpsURLConnection con = (HttpsURLConnection)url.openConnection();&lt;BR /&gt;con.setRequestMethod("POST");&lt;BR /&gt;con.setRequestProperty("Content-Type", "application/json");&lt;BR /&gt;con.setRequestProperty("Accept", "application/json");&lt;BR /&gt;&lt;BR /&gt;con.setDoOutput(true);&lt;/P&gt;&lt;P&gt;try(OutputStream os = con.getOutputStream()) {&lt;BR /&gt;byte[] input = jsonInputString.getBytes("utf-8");&lt;BR /&gt;os.write(input, 0, input.length);&lt;BR /&gt;}&lt;BR /&gt;print_content(con);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;private static String print_content(HttpsURLConnection con){&lt;BR /&gt;if(con!=null){&lt;/P&gt;&lt;P&gt;try {&lt;/P&gt;&lt;P&gt;// System.out.println("****** Content of the URL ********");&lt;/P&gt;&lt;P&gt;BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));&lt;/P&gt;&lt;P&gt;String input;&lt;BR /&gt;StringBuffer res=new StringBuffer();&lt;/P&gt;&lt;P&gt;while ((input = br.readLine()) != null){&lt;BR /&gt;res.append(input);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;System.out.println(res.toString());&lt;BR /&gt;String auth;&lt;BR /&gt;try {/*&lt;BR /&gt;JSONObject myres=new JSONObject(res.toString());&lt;BR /&gt;if(myres.has("access_token")) {&lt;BR /&gt;auth = myres.getString("access_token");&lt;BR /&gt;}else{&lt;BR /&gt;auth=null;&lt;BR /&gt;}*/&lt;BR /&gt;Pattern p1=Pattern.compile("\"access_token\":\"(.*?)\"");&lt;BR /&gt;Matcher m1=p1.matcher(res.toString());&lt;BR /&gt;m1.find();&lt;BR /&gt;auth = m1.group(1);&lt;BR /&gt;System.out.println(auth);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;BR /&gt;catch(Exception e){&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;//System.out.println(myres.getString("access_token"));&lt;BR /&gt;br.close();&lt;BR /&gt;return auth;&lt;/P&gt;&lt;P&gt;} catch (IOException e) {&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;}else{&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the exception is attached below:-&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 08:27:39 GMT</pubDate>
    <dc:creator>00uv2dq1dg5YHBFIx5d6</dc:creator>
    <dc:date>2021-06-23T08:27:39Z</dc:date>
    <item>
      <title>Have a Exception in java After importing the certificate</title>
      <link>https://community.cisco.com/t5/network-security/have-a-exception-in-java-after-importing-the-certificate/m-p/4422333#M1081718</link>
      <description>&lt;P&gt;I imported the certificate to java trusted certificates, it shows the some error.is it due to certificate is Self-signed ?.&lt;/P&gt;&lt;P&gt;And is there any way to overcome this problem other than overriding SSL certificate verification.&lt;/P&gt;&lt;P&gt;Is there any way to add SAN to the certificate&lt;/P&gt;&lt;P&gt;I have searched in some website but it shows it is due to the Hostname or common name mismatch but can you tell me how to rectify it&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;this is the program used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;package A;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;import javax.net.ssl.HostnameVerifier;&lt;BR /&gt;import javax.net.ssl.HttpsURLConnection;&lt;BR /&gt;import javax.net.ssl.SSLSession;&lt;BR /&gt;import java.io.BufferedReader;&lt;BR /&gt;import java.io.IOException;&lt;BR /&gt;import java.io.InputStreamReader;&lt;BR /&gt;import java.io.OutputStream;&lt;BR /&gt;import java.net.URL;&lt;BR /&gt;import java.util.regex.Matcher;&lt;BR /&gt;import java.util.regex.Pattern;&lt;/P&gt;&lt;P&gt;public class Main {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;public static void main(String[] args) throws IOException {&lt;BR /&gt;System.out.println(System.getProperty("java.home"));&lt;BR /&gt;String https_url = "&lt;A href="https://10.1.60.60/api/fdm/latest/fdm/token" target="_blank"&gt;https://10.1.60.60/api/fdm/latest/fdm/token&lt;/A&gt;";&lt;BR /&gt;String jsonInputString = "{\"grant_type\": \"password\", \"username\": \"admin\", \"password\": \"Ashok@188616\"}";&lt;BR /&gt;URL url = new URL(https_url);&lt;BR /&gt;HttpsURLConnection con = (HttpsURLConnection)url.openConnection();&lt;BR /&gt;con.setRequestMethod("POST");&lt;BR /&gt;con.setRequestProperty("Content-Type", "application/json");&lt;BR /&gt;con.setRequestProperty("Accept", "application/json");&lt;BR /&gt;&lt;BR /&gt;con.setDoOutput(true);&lt;/P&gt;&lt;P&gt;try(OutputStream os = con.getOutputStream()) {&lt;BR /&gt;byte[] input = jsonInputString.getBytes("utf-8");&lt;BR /&gt;os.write(input, 0, input.length);&lt;BR /&gt;}&lt;BR /&gt;print_content(con);&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;private static String print_content(HttpsURLConnection con){&lt;BR /&gt;if(con!=null){&lt;/P&gt;&lt;P&gt;try {&lt;/P&gt;&lt;P&gt;// System.out.println("****** Content of the URL ********");&lt;/P&gt;&lt;P&gt;BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));&lt;/P&gt;&lt;P&gt;String input;&lt;BR /&gt;StringBuffer res=new StringBuffer();&lt;/P&gt;&lt;P&gt;while ((input = br.readLine()) != null){&lt;BR /&gt;res.append(input);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;System.out.println(res.toString());&lt;BR /&gt;String auth;&lt;BR /&gt;try {/*&lt;BR /&gt;JSONObject myres=new JSONObject(res.toString());&lt;BR /&gt;if(myres.has("access_token")) {&lt;BR /&gt;auth = myres.getString("access_token");&lt;BR /&gt;}else{&lt;BR /&gt;auth=null;&lt;BR /&gt;}*/&lt;BR /&gt;Pattern p1=Pattern.compile("\"access_token\":\"(.*?)\"");&lt;BR /&gt;Matcher m1=p1.matcher(res.toString());&lt;BR /&gt;m1.find();&lt;BR /&gt;auth = m1.group(1);&lt;BR /&gt;System.out.println(auth);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;BR /&gt;catch(Exception e){&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;//System.out.println(myres.getString("access_token"));&lt;BR /&gt;br.close();&lt;BR /&gt;return auth;&lt;/P&gt;&lt;P&gt;} catch (IOException e) {&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;}else{&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the exception is attached below:-&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 08:27:39 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/have-a-exception-in-java-after-importing-the-certificate/m-p/4422333#M1081718</guid>
      <dc:creator>00uv2dq1dg5YHBFIx5d6</dc:creator>
      <dc:date>2021-06-23T08:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Have a Exception in java After importing the certificate</title>
      <link>https://community.cisco.com/t5/network-security/have-a-exception-in-java-after-importing-the-certificate/m-p/4422410#M1081723</link>
      <description>&lt;P&gt;this error happens when I try to use rest Api in java&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 10:24:05 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-security/have-a-exception-in-java-after-importing-the-certificate/m-p/4422410#M1081723</guid>
      <dc:creator>00uv2dq1dg5YHBFIx5d6</dc:creator>
      <dc:date>2021-06-23T10:24:05Z</dc:date>
    </item>
  </channel>
</rss>

