java - How to set trust manager in Spring to connect to webservice over https -
i'm stuck! tried said in internet no luck. there webservice configured ssl , want send soap message server on https. here message sender i've created spring:
public class keystoreawaremessagesender extends httpsurlconnectionmessagesender {
public cbiskeystoreawaremessagesender() { try { keystore ks = keystore.getinstance("jks"); inputstream = new fileinputstream("d:\\dev\\keystore\\my-keystore.jks"); ks.load(is, "mypass1".tochararray()); setsslprotocol("tlsv1"); sslcontext c = sslcontext.getinstance("tlsv1"); certificatefactory cf = certificatefactory.getinstance("x.509"); trustmanagerfactory tmf = trustmanagerfactory.getinstance(trustmanagerfactory.getdefaultalgorithm()); tmf.init(ks); super.settrustmanagers(tmf.gettrustmanagers()); //x509trustmanager defaulttrustmanager = (x509trustmanager) tmf.gettrustmanagers()[0]; keymanagerfactory kmf = keymanagerfactory.getinstance(keymanagerfactory.getdefaultalgorithm()); kmf.init(ks, "cbis1".tochararray()); super.setkeymanagers(kmf.getkeymanagers()); c.init(kmf.getkeymanagers(), tmf.gettrustmanagers(), new securerandom()); sslcontext.setdefault(c); } catch (exception ex) { // todo auto-generated catch block ex.printstacktrace(); } }
}
this doesn't work @ , keep getting error says: {
main, send tlsv1 alert: warning, description = close_notify padded plaintext before encryption: len = 32 0000: 01 00 1d 98 ec 71 99 52 6c 48 42 70 08 9e e1 8c .....q.rlhbp.... 0010: 4e a4 22 98 73 63 09 09 09 09 09 09 09 09 09 09 n.".sc.......... main, write: tlsv1 alert, length = 32 [raw write]: length = 37 0000: 15 03 01 00 20 6a 5c d0 f6 5b de 70 bf 9b de 0c .... j\..[.p.... 0010: ce 66 80 79 ab c0 d5 d0 6f c9 02 40 0b 75 c4 ab .f.y....o..@.u.. 0020: 6f b2 6b e6 6e o.k.n main, called closesocket(selfinitiated) 20:45:52.686 [main] debug o.s.w.client.messagetracing.received - received response [saajsoapmessage {http://schemas.xmlsoap.org/soap/envelope/}fault] request [saajsoapmessage {http://www.aegon.co.uk/namespaces/trustedthirdparty}newentrantinvestorrequest] 20:45:52.686 [main] debug o.s.w.client.core.webservicetemplate - received fault message request [saajsoapmessage {http://www.aegon.co.uk/namespaces/trustedthirdparty}newentrantinvestorrequest] exception in thread "main" org.springframework.ws.soap.client.soapfaultclientexception: not access envelope: unable create envelope given source: ; nested exception com.sun.xml.messaging.saaj.soapexceptionimpl: unable create envelope given source: @ org.springframework.ws.soap.client.core.soapfaultmessageresolver.resolvefault(soapfaultmessageresolver.java:37) @ org.springframework.ws.client.core.webservicetemplate.handlefault(webservicetemplate.java:774) @ org.springframework.ws.client.core.webservicetemplate.dosendandreceive(webservicetemplate.java:600) @ org.springframework.ws.client.core.webservicetemplate.sendandreceive(webservicetemplate.java:537) @ org.springframework.ws.client.core.webservicetemplate.marshalsendandreceive(webservicetemplate.java:384) @ org.springframework.ws.client.core.webservicetemplate.marshalsendandreceive(webservicetemplate.java:378) @ org.springframework.ws.client.core.webservicetemplate.marshalsendandreceive(webservicetemplate.java:370)
}
please me on this!
Comments
Post a Comment