Исключение в основном потоке javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: нет альтернативных имен субъектов

Мы тестируем пример приложения на веб-сайте Cisco DevNet, который демонстрирует, как создать клиент-потребитель веб-службы Extension Mobility. Мы выполнили инструкции и импортировали сертификат в хранилище ключей, но он все равно не работает.

Вот ссылка на образец: https://developer.cisco.com/site/extension-mobility/learn/sample-apps/index.gsp

Вот сообщение об ошибке:

Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present

Когда я тестирую с небезопасным соединением, используйте URL-адрес как

http:/<x.x.x.x>/:8080/emservice/EMServiceServlet

Он показывает сообщение об ошибке 500:

java.lang.NullPointerException
java.lang.String.<init>(String.java:147)
com.cisco.emservice.EMServiceServlet.processRequest(EMServiceServlet.java:204)
com.cisco.emservice.EMServiceServlet.doPost(EMServiceServlet.java:451)
com.cisco.emservice.EMServiceServlet.doGet(EMServiceServlet.java:385)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)

Вот мой код:

public class Workplace {
public static void main(String[] args) throws Exception {

    URL url = new URL("https://192.168.10.11:8443/emservice/EMServiceServlet");
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

    String EMRequest = "<request><appinfo><appid>operator</appid><appcertificate>operator</appcertificate></appinfo>";
    EMRequest += "<login><devicename>SEP000000000001</devicename><userid>user01</userid><deviceprofile>EM-USER01/deviceprofile>";
    EMRequest += "<exclusiveduration><time>60</time></exclusiveduration></login></request>";
    //URL encode/escape the request
    EMRequest = URLEncoder.encode(EMRequest,"UTF-8");
    //Build the complete HTTP form request body
    EMRequest = "xml="+EMRequest;

    //Create an OutputStreamWriter for the URLConnection object and make the request
    OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
    writer.write(EMRequest);
    writer.flush();

    //Read the response
    BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

    //Output the response to the console
    String line;
    while ((line = reader.readLine()) != null) {
    System.out.println(line);
    }

    //Cleanup the stream objects
    writer.close();
    reader.close();
    }
}

есть ли решение этой проблемы? Спасибо...


person veronfort    schedule 11.08.2015    source источник
comment
Вы пытаетесь получить доступ к веб-службе с поддержкой SSL через http вместо https. Попробуйте использовать https://:8443/emservice/EMServiceServlet или что-то в этом роде.   -  person Tim Biegeleisen    schedule 11.08.2015
comment
Я использовал https, но он все равно не работает. Сообщение об ошибке такое же, как и предыдущее.   -  person veronfort    schedule 11.08.2015
comment
Можете ли вы включить код Java, который вы использовали для доступа к URL-адресу?   -  person Tim Biegeleisen    schedule 11.08.2015
comment
Дубликат stackoverflow.com/q/17167691/207421   -  person user207421    schedule 11.08.2015
comment
Есть код, который я использую   -  person veronfort    schedule 11.08.2015
comment
О чем ты спрашиваешь? Исключение для рукопожатия? Или НПЭ?   -  person user207421    schedule 11.08.2015
comment
оба, но рукопожатие является самым важным. спасибо   -  person veronfort    schedule 11.08.2015
comment
CertificateException происходит из-за сертификата на сервере, к которому вы подключаетесь; см. stackoverflow.com/questions/10258101/ для аналогичной ситуации. Обходной путь setDefaultHostnameVerifier в этом сообщении может сработать для вас.   -  person Castaglia    schedule 17.02.2016