[ https://issues.apache.org/jira/browse/CXF-4053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp resolved CXF-4053. ------------------------------ Resolution: Incomplete Fix Version/s: Invalid This really would need to go to the us...@cxf.apache.org list with additional details about configuration and such. We obviously have a lot of tests that use and configure https. > Runtime error while connecting to the Secure(https) WebService from Apache > CXF Client > -------------------------------------------------------------------------------------- > > Key: CXF-4053 > URL: https://issues.apache.org/jira/browse/CXF-4053 > Project: CXF > Issue Type: Task > Components: Core > Affects Versions: 2.4.4 > Environment: Windows > Reporter: Srinivas A > Fix For: Invalid > > Original Estimate: 168h > Remaining Estimate: 168h > > Hi > I am working on Developing ApacheCXF Client for Secured(HTTPS) Axis1 > WebService. The Axis1 Service Side people were given me the 3 keystore > files(keystore.jks,cacerts,server_sankey.jks).I Loaded those 3 files in my > client by giving the respective passwords.I did not get any error while > loading the keystores but I got an error while invoking the service. I am > sending my Client program as follows.But while working with HTTP it is > working fine.Iam fighting with it for 7 days.Kindly solve my problem. My code > is as follows > {code:java} > import java.io.File; > import java.io.FileInputStream; > import java.io.FileNotFoundException; > import java.io.IOException; > import java.lang.reflect.InvocationHandler; > import java.lang.reflect.Proxy; > import java.net.URL; > import java.security.GeneralSecurityException; > import java.security.KeyStore; > import java.security.KeyStoreException; > import java.security.NoSuchAlgorithmException; > import java.security.UnrecoverableKeyException; > import java.security.cert.CertificateException; > import java.util.ArrayList; > import java.util.Date; > import java.util.GregorianCalendar; > import java.util.List; > import java.util.Map; > import javax.net.ssl.KeyManager; > import javax.net.ssl.KeyManagerFactory; > import javax.net.ssl.TrustManager; > import javax.net.ssl.TrustManagerFactory; > import javax.xml.bind.JAXBElement; > import javax.xml.bind.JAXBException; > import javax.xml.datatype.DatatypeConfigurationException; > import javax.xml.datatype.DatatypeFactory; > import javax.xml.datatype.XMLGregorianCalendar; > import javax.xml.namespace.QName; > import javax.xml.ws.BindingProvider; > import org.apache.cxf.configuration.jsse.TLSClientParameters; > import org.apache.cxf.configuration.security.FiltersType; > import org.apache.cxf.endpoint.Client; > import org.apache.cxf.frontend.ClientProxy; > import org.apache.cxf.headers.Header; > import org.apache.cxf.interceptor.LoggingInInterceptor; > import org.apache.cxf.interceptor.LoggingOutInterceptor; > import org.apache.cxf.jaxb.JAXBDataBinding; > import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; > import org.apache.cxf.transport.http.HTTPConduit; > import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; > import com.sun.xml.internal.ws.client.Stub; > public class CustomerTest { > public static void main(String[] args)throws Exception { > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > factory.setServiceClass(InquiryPortType.class); > factory.getInInterceptors().add(new LoggingInInterceptor()); > factory.getOutInterceptors().add(new LoggingOutInterceptor()); > factory.setAddress("https://192.168.1.45:4444/axis/customerProfile/inquiry/2010/11"); > > InquiryPortType service=(InquiryPortType) factory.create(); > Client client = ClientProxy.getClient(service); > HTTPConduit http = (HTTPConduit)client.getConduit(); > TLSClientParameters tlsParams=new TLSClientParameters(); > tlsParams.setSecureSocketProtocol("SSL"); > String trustpass = "password"; > TrustManagerFactory trustFactory = > TrustManagerFactory.getInstance(TrustManagerFactory > .getDefaultAlgorithm()); > KeyStore keyStore = KeyStore.getInstance("JKS"); > File truststore = new File("C:\\repository\\server_sankey.jks"); > keyStore.load(new FileInputStream(truststore), trustpass.toCharArray()); > trustFactory.init(keyStore); > TrustManager[] tm1 = trustFactory.getTrustManagers(); > //tlsParams.setTrustManagers(tm1); > trustpass="password"; > TrustManagerFactory trustFactory1 = > TrustManagerFactory.getInstance(TrustManagerFactory > .getDefaultAlgorithm()); > KeyStore keyStore1 = KeyStore.getInstance("JKS"); > File truststore1 = new File("C:\\repository\\keystore.jks"); > keyStore1.load(new FileInputStream(truststore1), trustpass.toCharArray()); > trustFactory1.init(keyStore1); > TrustManager[] tm2 = trustFactory1.getTrustManagers(); > trustpass="password"; > TrustManagerFactory trustFactory2 = > TrustManagerFactory.getInstance(TrustManagerFactory > .getDefaultAlgorithm()); > KeyStore keyStore2 = KeyStore.getInstance("JKS"); > File truststore2 = new File("C:\\repository\\cacerts"); > keyStore2.load(new FileInputStream(truststore2), trustpass.toCharArray()); > trustFactory2.init(keyStore2); > TrustManager[] tm = trustFactory2.getTrustManagers(); > List<TrustManager> trustList=new ArrayList<TrustManager>(); > for (int i = 0; i < tm.length; i++) { > trustList.add(tm[i]); > } > for (int i = 0; i < tm1.length; i++) { > trustList.add(tm1[i]); > } > for (int i = 0; i < tm2.length; i++) { > trustList.add(tm2[i]); > } > TrustManager[] tms=new TrustManager[trustList.size()]; > tms=trustList.toArray(tms); > tlsParams.setTrustManagers(tms); > FiltersType cipher_suite_filter = new FiltersType(); > cipher_suite_filter.getInclude().add("SSL_RSA_WITH_3DES_EDE_CBC_SHA"); > cipher_suite_filter.getExclude().add(".*_DH_anon_.*"); > tlsParams.setCipherSuitesFilter(cipher_suite_filter); > http.setTlsClientParameters(tlsParams); > HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); > httpClientPolicy.setReceiveTimeout(10000); > http.setClient(httpClientPolicy); > SearchMidSessionReviewRequestType request=new > SearchMidSessionReviewRequestType(); > request.setBehaviorVersion(new Short("0")); > SelectionCritieriaType selectionCritieriaType=new SelectionCritieriaType(); > selectionCritieriaType.setAUNumber("12345"); > request.setSelectionCriteria(selectionCritieriaType); > InitiatorInformationType initiatorInformationType=new > InitiatorInformationType(); > ChannelInfoType channelInfoType=new ChannelInfoType(); > channelInfoType.setInitiatorCompanyNbr("300"); > initiatorInformationType.setChannelInfo(channelInfoType); > request.setInitiatorInformation(initiatorInformationType); > java.util.Map<String, Object> requestContext = > ((javax.xml.ws.BindingProvider)service).getRequestContext(); > Header h1= new Header( > new QName("http://service.wellsfargo.com/entity/message/2003/", "WFContext"), > "decapitated", > new JAXBDataBinding(WFContextType.class)); > h1.setObject(getWFContext("22970", "Test")); > List<Header> holder=new ArrayList<Header>(); > holder.add(h1); > ((BindingProvider)service).getRequestContext().put(Header.HEADER_LIST,holder); > > GetCustomerInformationRequestType r=new GetCustomerInformationRequestType(); > service.getCustomerInformation(r); > } > public static XMLGregorianCalendar asXMLGregorianCalendar(java.util.Date > date) > { > DatatypeFactory df ; > try > { > df = DatatypeFactory.newInstance(); > } catch (DatatypeConfigurationException dce) > { > throw new IllegalStateException("Exception while obtaining DatatypeFactory > instance", dce); > } > if (date == null) > { > return null; > } > else > { > GregorianCalendar gc = new GregorianCalendar(); > gc.setTimeInMillis(date.getTime()); > return df.newXMLGregorianCalendar(gc); > } > } > public static URL getURL(String environment, String service) throws Exception > { > try { > return new URL(environment + service); > } > catch (java.net.MalformedURLException e) { > e.printStackTrace(); > return null; > } > } > public static WFContextType getWFContext(String initiatorId, String > invokerId) throws Exception { > WFContextType wfContext = new WFContextType(); > wfContext.setActivitySourceId("KO"); > wfContext.setActivitySourceIdType("FNC"); > wfContext.setSubActivitySourceId("SimpleSoapClient"); > wfContext.setBillingAU("47150"); > wfContext.setCreationTimestamp(asXMLGregorianCalendar(new Date())); > wfContext.setHostName(java.net.InetAddress.getLocalHost().getHostName()); > wfContext.setInitiatorId(initiatorId); > wfContext.setInitiatorIdType("HRIS"); > wfContext.setInvokerId(invokerId); > wfContext.setMessageId("searchMidSessionReview201202"); > wfContext.setOriginatorId("501881234"); > wfContext.setOriginatorIdType("TIN"); > return wfContext; > } > } > {code} > Error is: > {code} > Jan 16, 2012 4:31:46 AM > org.apache.cxf.service.factory.ReflectionServiceFactoryBean > buildServiceFromClass > INFO: Creating Service > {http://service.wellsfargo.com/provider/customerProfile/inquiry/2010/11/}InquiryPortTypeService > from class > com.wellsfargo.service.provider.customerprofile.inquiry._2010._11.InquiryPortType > > Jan 16, 2012 4:32:03 AM org.apache.cxf.phase.PhaseInterceptorChain > doDefaultLogging > WARNING: Interceptor for > {http://service.com/provider/customerProfile/inquiry/2010/11/}InquiryPortTypeService#{http://service.wellsfargo.com/provider/customerProfile/inquiry/2010/11/}getCustomerInformation > has thrown exception, unwinding now > org.apache.cxf.interceptor.Fault: Marshalling Error: Received fatal alert: > unexpected_message > at > org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:257) > at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169) > at > org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110) > > at > org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) > > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) > > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:533) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88) > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) > at $Proxy57.getCustomerInformation(Unknown Source) > at com.customerProfile.inquiry.CustomerTest.main(CustomerTest.java:161) > Caused by: javax.xml.bind.MarshalException > - with linked exception: > [javax.net.ssl.SSLException: Received fatal alert: unexpected_message] > at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:333) > at > com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) > at > javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) > > at > org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:550) > > at > org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:232) > ... 12 more > Caused by: javax.net.ssl.SSLException: Received fatal alert: > unexpected_message > at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190) > at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138) > > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165) > > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149) > > at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434) > at > sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166) > > at > sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014) > > at > sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230) > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1367) > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1309) > > at > org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) > > at > org.apache.cxf.io.AbstractThresholdOutputStream.unBuffer(AbstractThresholdOutputStream.java:89) > > at > org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:63) > > at > org.apache.cxf.io.CacheAndWriteOutputStream.write(CacheAndWriteOutputStream.java:68) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:395) > > at com.sun.xml.bind.v2.runtime.output.Encoded.write(Encoded.java:163) > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.doText(UTF8XmlOutput.java:306) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.writeNsDecl(UTF8XmlOutput.java:220) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.writeNsDecls(UTF8XmlOutput.java:200) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.beginStartTag(UTF8XmlOutput.java:159) > > at > com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.startElement(NamespaceContextImpl.java:483) > > at > com.sun.xml.bind.v2.runtime.XMLSerializer.endNamespaceDecls(XMLSerializer.java:283) > > at > com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:674) > > at > com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:150) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:71) > > at > com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490) > at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) > ... 16 more > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Marshalling > Error: Received fatal alert: unexpected_message > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) > at $Proxy57.getCustomerInformation(Unknown Source) > at com.customerProfile.inquiry.CustomerTest.main(CustomerTest.java:161) > Caused by: javax.xml.bind.MarshalException > - with linked exception: > [javax.net.ssl.SSLException: Received fatal alert: unexpected_message] > at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:333) > at > com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) > at > javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) > > at > org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:550) > > at > org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:232) > at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169) > at > org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110) > > at > org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) > > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) > > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:533) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319) > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88) > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) > ... 2 more > Caused by: javax.net.ssl.SSLException: Received fatal alert: > unexpected_message > at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190) > at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954) > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138) > > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165) > > at > com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149) > > at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434) > at > sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166) > > at > sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014) > > at > sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230) > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1367) > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1309) > > at > org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42) > > at > org.apache.cxf.io.AbstractThresholdOutputStream.unBuffer(AbstractThresholdOutputStream.java:89) > > at > org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:63) > > at > org.apache.cxf.io.CacheAndWriteOutputStream.write(CacheAndWriteOutputStream.java:68) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.write(UTF8XmlOutput.java:395) > > at com.sun.xml.bind.v2.runtime.output.Encoded.write(Encoded.java:163) > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.doText(UTF8XmlOutput.java:306) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.writeNsDecl(UTF8XmlOutput.java:220) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.writeNsDecls(UTF8XmlOutput.java:200) > > at > com.sun.xml.bind.v2.runtime.output.UTF8XmlOutput.beginStartTag(UTF8XmlOutput.java:159) > > at > com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl$Element.startElement(NamespaceContextImpl.java:483) > > at > com.sun.xml.bind.v2.runtime.XMLSerializer.endNamespaceDecls(XMLSerializer.java:283) > > at > com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:674) > > at > com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:150) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:185) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:305) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:312) > > at > com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:71) > > at > com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490) > at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) > ... 16 more > {code} > Waiting for your reply... -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira