XML-RPC over SSL in MATLAB
Show older comments
Hello. I am trying to access a server that uses a xml-rpc communication layer with ssl. The only documentation I have found for xmlrpc in MATLAB is here: https://wiki.nbic.nl/index.php/Matlab_XMLRPC. I have downloaded the following JAR files and added their paths to $matlabroot/toolbox/local/classpath.txt:
- ws-commons-util-1.0.2.jar
- xmlrpc-client-3.1.3.jar
- xmlrpc-common-3.1.3.jar
- xmlrpc-server-3.1.3.jar
My code looks something like this:
username = 'username';
password = 'password';
ip = '55.555.55.555';
port = 8080;
xmlrpc_url = sprintf('https://%s:%s@%s:%i/',...
username,password,ip,port);
client = javaObject('org.apache.xmlrpc.client.XmlRpcClient')
config = javaObject('org.apache.xmlrpc.client.XmlRpcClientConfigImpl')
url = javaObject('java.net.URL', xmlrpc_url)
config.setServerURL(url)
client.setConfig(config)
client.execute('list.Methods', '')
When I run it I get the following errors:
Java exception occurred:
org.apache.xmlrpc.XmlRpcException: Failed to read server's response:
java.security.cert.CertificateException: No subject alternative names
present
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:161)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
Caused by: javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative names
present
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
at
sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
at
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at
sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.writeRequest(XmlRpcSunHttpTransport.java:104)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)
... 6 more
Caused by: java.security.cert.CertificateException: No subject
alternative names present
at
sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:145)
at
sun.security.util.HostnameChecker.match(HostnameChecker.java:94)
at
sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at
sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
at
sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
at
sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
... 20 more
Caused by:
javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative names
present
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
at
sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
at
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at
sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.writeRequest(XmlRpcSunHttpTransport.java:104)
at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)
at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at
org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at
org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
Caused by: java.security.cert.CertificateException: No subject
alternative names present
at
sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:145)
at
sun.security.util.HostnameChecker.match(HostnameChecker.java:94)
at
sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at
sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
at
sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
at
sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at
sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
... 20 more
I believe I need to somehow specify the use of SSL, but I know very little about networking or the use of Java classes/methods (much less in a MATLAB environment). Any advice?
Answers (2)
Benjamin Sunderland
on 21 Aug 2018
Feyza Boyun
on 18 Jul 2021
fileplace='/location/of/your/jar/files/';
dpath={[fileplace, 'commons-logging-1.1.jar'], ...
[fileplace, 'ws-commons-util-1.0.2.jar'], ...
[fileplace, 'xmlrpc-common-3.1.3.jar'], ...
[fileplace, 'xmlrpc-client-3.1.3.jar'], ...
[fileplace, 'xmlrpc-server-3.1.3.jar'] ...
};
javaclasspath(dpath)
% Setting up the client
client = javaObject('org.apache.xmlrpc.client.XmlRpcClient')
config = javaObject('org.apache.xmlrpc.client.XmlRpcClientConfigImpl')
url = javaObject('java.net.URL', 'http://localhost:(9000/')
config.setServerURL(url)
config.setEnabledForExtensions(true);
config.setConnectionTimeout(60 * 1000);
config.setReplyTimeout(60 * 1000);
client.setConfig(config)
try this, it works for me.
Categories
Find more on Call Web Services from MATLAB Using HTTP in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!