Мы тестируем пример приложения на веб-сайте 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();
}
}
есть ли решение этой проблемы? Спасибо...
http
вместоhttps
. Попробуйте использоватьhttps://:8443/emservice/EMServiceServlet
или что-то в этом роде. - person Tim Biegeleisen   schedule 11.08.2015CertificateException
происходит из-за сертификата на сервере, к которому вы подключаетесь; см. stackoverflow.com/questions/10258101/ для аналогичной ситуации. Обходной путьsetDefaultHostnameVerifier
в этом сообщении может сработать для вас. - person Castaglia   schedule 17.02.2016