You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by pchiru <J2...@gmail.com> on 2013/10/25 02:23:00 UTC

java.lang.IllegalArgumentException: not an RSA key!at org.bouncycastle.jce.provider.JCERSACipher.engineGetKeySize(Unknown Source)

Hi,
I am trying to test CXF Timestamp Signature Encrypt EXAMPLE. I have
generated key stores for client and server and kept under the relevant
folders.

/*I have the following configuration for the jaxws:endpoint.*/


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

	
	<bean id="personServ" class="com.unitedcoders.demo.PersonServiceImpl" />

	
	 <bean id="logInBound"
class="org.apache.cxf.interceptor.LoggingInInterceptor" />

 	<bean id="logOutBound"
class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
 	
	<jaxws:endpoint id="personService" implementor="#personServ"
		address="/personService">
		<jaxws:inInterceptors>
			<ref bean="logInBound" />
			<ref bean="inbound-security" />
			
		</jaxws:inInterceptors>
		<jaxws:outInterceptors>
			<ref bean="logOutBound" />
			<ref bean="outbound-security" />
		</jaxws:outInterceptors>
		
		
		
	</jaxws:endpoint>
	<bean id="inbound-security"
class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
		<constructor-arg>
			<map>
				
				<entry key="action" value="Timestamp Signature Encrypt"/>  
				<entry
				
key="#{T(org.apache.ws.security.handler.WSHandlerConstants).SIG_PROP_FILE}"
					value="server-crypto.properties">
				</entry>
				<entry
				
key="#{T(org.apache.ws.security.handler.WSHandlerConstants).DEC_PROP_FILE}"
					value="server-crypto.properties">
				</entry>
				<entry
				
key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
					<ref bean="myPasswordCallback" />
				</entry>
			</map>
		</constructor-arg>
	</bean>
	 <bean id="outbound-security"
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
	 <constructor-arg>

            <map>

                <entry key="action" value="Timestamp Signature Encrypt"/>  

                <entry key="user" value="server"/>              

                <entry key="signaturePropFile"
value="server-crypto.properties"/>

                <entry key="encryptionPropFile"
value="server-crypto.properties"/>

                <entry key="encryptionUser" value="useReqSigCert"/>

               <entry
				
key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
					<ref bean="myPasswordCallback" />
				</entry>

                <entry key="signatureParts"
value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>

                <entry key="encryptionParts"
value="{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>

                <entry key="encryptionSymAlgorithm"
value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>

            </map>

        </constructor-arg>

    </bean>   
	
	<bean class="com.unitedcoders.security.ServerPasswordCallback"
		id="myPasswordCallback" />
	
</beans>



/*I have the following configuration for the jaxws:client.*/


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

	
	<bean id="personServ" class="com.unitedcoders.demo.PersonServiceImpl" />

	

	<bean id="logOutBound"
class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
	<bean id="logInBound"
class="org.apache.cxf.interceptor.LoggingInInterceptor" />
	<jaxws:client id="personServiceClient"
serviceClass="com.unitedcoders.demo.PersonService"
		address="http://localhost:8080/CXFExampleService">
		<jaxws:inInterceptors>

			<ref bean="logInBound" />

			<ref bean="inbound-security" />

		</jaxws:inInterceptors>
		<jaxws:outInterceptors>

			<ref bean="logOutBound" />

			<ref bean="outbound-security" />

		</jaxws:outInterceptors>

	</jaxws:client>
	<bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
		id="outbound-security">

		<constructor-arg>

			<map>

				<entry key="action" value="Timestamp Signature Encrypt" />

				<entry key="user" value="client" />

				<entry key="signaturePropFile" value="client-crypto.properties" />

				<entry key="encryptionPropFile" value="client-crypto.properties" />

				<entry key="signatureKeyIdentifier" value="DirectReference" />

				<entry key="encryptionUser" value="server" />

				<entry
				
key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
					<ref bean="clientPasswordCallback" />
				</entry>

				<entry key="signatureParts"
value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
                
                <entry key="encryptionParts"
value="{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
               
                <entry key="encryptionSymAlgorithm"
value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/> 
            </map>

		</constructor-arg>

	</bean>

	<bean class="com.unitedcoders.client.ClientPasswordCallback"
id="clientPasswordCallback" />
	<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
		id="inbound-security">

		<constructor-arg>

			<map>

				<entry key="action" value="Timestamp Signature Encrypt" />

				<entry key="signaturePropFile" value="client-crypto.properties" />

				<entry key="decryptionPropFile" value="client-crypto.properties" />

				<entry
				
key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
					<ref bean="clientPasswordCallback" />
				</entry>

			</map>

		</constructor-arg>

	</bean>
</beans>

/*I have deployed the service to tomcat successfully.

when I run the client below.*/

ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext(new String[]{"client-context.xml"});
		System.out.println("Context"+context.getBeanDefinitionCount());
		PersonService client =
(PersonService)context.getBean("personServiceClient");
		System.out.println("Client:" +client.greetPerson("Padma"));
/*
I am getting the following exception.*/


 Interceptor for
{http://demo.unitedcoders.com/}PersonServiceService#{http://demo.unitedcoders.com/}greetPerson
has thrown exception, unwinding now
java.lang.IllegalArgumentException: not an RSA key!
	at org.bouncycastle.jce.provider.JCERSACipher.engineGetKeySize(Unknown
Source)
	at javax.crypto.Cipher.b(DashoA13*..)
	at javax.crypto.Cipher.a(DashoA13*..)
	at javax.crypto.Cipher.a(DashoA13*..)
	at javax.crypto.Cipher.a(DashoA13*..)
	at javax.crypto.Cipher.init(DashoA13*..)
	at javax.crypto.Cipher.init(DashoA13*..)
	at
org.apache.ws.security.message.WSSecEncryptedKey.prepareInternal(WSSecEncryptedKey.java:257)
	at
org.apache.ws.security.message.WSSecEncrypt.prepare(WSSecEncrypt.java:182)
	at org.apache.ws.security.message.WSSecEncrypt.build(WSSecEncrypt.java:223)
	at
org.apache.ws.security.action.EncryptionAction.execute(EncryptionAction.java:95)
	at
org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:232)
	at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$200(WSS4JOutInterceptor.java:52)
	at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:260)
	at
org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:136)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
	at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
	at com.sun.proxy.$Proxy36.greetPerson(Unknown Source)
	at
com.unitedcoders.client.PersonServiceClient.main(PersonServiceClient.java:21)

Please help me figure out this issue



--
View this message in context: http://cxf.547215.n5.nabble.com/java-lang-IllegalArgumentException-not-an-RSA-key-at-org-bouncycastle-jce-provider-JCERSACipher-engi-tp5735564.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: java.lang.IllegalArgumentException: not an RSA key!at org.bouncycastle.jce.provider.JCERSACipher.engineGetKeySize(Unknown Source)

Posted by Colm O hEigeartaigh <co...@apache.org>.
The error states that the keys you have generated are not RSA keys. How did
you generate the keystores?

Colm.


On Fri, Oct 25, 2013 at 1:23 AM, pchiru <J2...@gmail.com> wrote:

> Hi,
> I am trying to test CXF Timestamp Signature Encrypt EXAMPLE. I have
> generated key stores for client and server and kept under the relevant
> folders.
>
> /*I have the following configuration for the jaxws:endpoint.*/
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
>         xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
>
>         <import resource="classpath:META-INF/cxf/cxf.xml" />
>         <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>         <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>
>         <bean id="personServ"
> class="com.unitedcoders.demo.PersonServiceImpl" />
>
>
>          <bean id="logInBound"
> class="org.apache.cxf.interceptor.LoggingInInterceptor" />
>
>         <bean id="logOutBound"
> class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
>
>         <jaxws:endpoint id="personService" implementor="#personServ"
>                 address="/personService">
>                 <jaxws:inInterceptors>
>                         <ref bean="logInBound" />
>                         <ref bean="inbound-security" />
>
>                 </jaxws:inInterceptors>
>                 <jaxws:outInterceptors>
>                         <ref bean="logOutBound" />
>                         <ref bean="outbound-security" />
>                 </jaxws:outInterceptors>
>
>
>
>         </jaxws:endpoint>
>         <bean id="inbound-security"
> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
>                 <constructor-arg>
>                         <map>
>
>                                 <entry key="action" value="Timestamp
> Signature Encrypt"/>
>                                 <entry
>
> key="#{T(org.apache.ws.security.handler.WSHandlerConstants).SIG_PROP_FILE}"
>                                         value="server-crypto.properties">
>                                 </entry>
>                                 <entry
>
> key="#{T(org.apache.ws.security.handler.WSHandlerConstants).DEC_PROP_FILE}"
>                                         value="server-crypto.properties">
>                                 </entry>
>                                 <entry
>
>
> key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
>                                         <ref bean="myPasswordCallback" />
>                                 </entry>
>                         </map>
>                 </constructor-arg>
>         </bean>
>          <bean id="outbound-security"
> class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
>          <constructor-arg>
>
>             <map>
>
>                 <entry key="action" value="Timestamp Signature Encrypt"/>
>
>                 <entry key="user" value="server"/>
>
>                 <entry key="signaturePropFile"
> value="server-crypto.properties"/>
>
>                 <entry key="encryptionPropFile"
> value="server-crypto.properties"/>
>
>                 <entry key="encryptionUser" value="useReqSigCert"/>
>
>                <entry
>
>
> key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
>                                         <ref bean="myPasswordCallback" />
>                                 </entry>
>
>                 <entry key="signatureParts"
> value="{Element}{
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body
> "/>
>
>                 <entry key="encryptionParts"
> value="{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
>
>                 <entry key="encryptionSymAlgorithm"
> value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
>
>             </map>
>
>         </constructor-arg>
>
>     </bean>
>
>         <bean class="com.unitedcoders.security.ServerPasswordCallback"
>                 id="myPasswordCallback" />
>
> </beans>
>
>
>
> /*I have the following configuration for the jaxws:client.*/
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
>         xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
>
>         <import resource="classpath:META-INF/cxf/cxf.xml" />
>         <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>
>         <bean id="personServ"
> class="com.unitedcoders.demo.PersonServiceImpl" />
>
>
>
>         <bean id="logOutBound"
> class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
>         <bean id="logInBound"
> class="org.apache.cxf.interceptor.LoggingInInterceptor" />
>         <jaxws:client id="personServiceClient"
> serviceClass="com.unitedcoders.demo.PersonService"
>                 address="http://localhost:8080/CXFExampleService">
>                 <jaxws:inInterceptors>
>
>                         <ref bean="logInBound" />
>
>                         <ref bean="inbound-security" />
>
>                 </jaxws:inInterceptors>
>                 <jaxws:outInterceptors>
>
>                         <ref bean="logOutBound" />
>
>                         <ref bean="outbound-security" />
>
>                 </jaxws:outInterceptors>
>
>         </jaxws:client>
>         <bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
>                 id="outbound-security">
>
>                 <constructor-arg>
>
>                         <map>
>
>                                 <entry key="action" value="Timestamp
> Signature Encrypt" />
>
>                                 <entry key="user" value="client" />
>
>                                 <entry key="signaturePropFile"
> value="client-crypto.properties" />
>
>                                 <entry key="encryptionPropFile"
> value="client-crypto.properties" />
>
>                                 <entry key="signatureKeyIdentifier"
> value="DirectReference" />
>
>                                 <entry key="encryptionUser" value="server"
> />
>
>                                 <entry
>
>
> key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
>                                         <ref bean="clientPasswordCallback"
> />
>                                 </entry>
>
>                                 <entry key="signatureParts"
> value="{Element}{
> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body
> "/>
>
>                 <entry key="encryptionParts"
> value="{Element}{
> http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body
> "/>
>
>                 <entry key="encryptionSymAlgorithm"
> value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
>             </map>
>
>                 </constructor-arg>
>
>         </bean>
>
>         <bean class="com.unitedcoders.client.ClientPasswordCallback"
> id="clientPasswordCallback" />
>         <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
>                 id="inbound-security">
>
>                 <constructor-arg>
>
>                         <map>
>
>                                 <entry key="action" value="Timestamp
> Signature Encrypt" />
>
>                                 <entry key="signaturePropFile"
> value="client-crypto.properties" />
>
>                                 <entry key="decryptionPropFile"
> value="client-crypto.properties" />
>
>                                 <entry
>
>
> key="#{T(org.apache.ws.security.handler.WSHandlerConstants).PW_CALLBACK_REF}">
>                                         <ref bean="clientPasswordCallback"
> />
>                                 </entry>
>
>                         </map>
>
>                 </constructor-arg>
>
>         </bean>
> </beans>
>
> /*I have deployed the service to tomcat successfully.
>
> when I run the client below.*/
>
> ClassPathXmlApplicationContext context = new
> ClassPathXmlApplicationContext(new String[]{"client-context.xml"});
>
> System.out.println("Context"+context.getBeanDefinitionCount());
>                 PersonService client =
> (PersonService)context.getBean("personServiceClient");
>                 System.out.println("Client:" +client.greetPerson("Padma"));
> /*
> I am getting the following exception.*/
>
>
>  Interceptor for
> {
> http://demo.unitedcoders.com/}PersonServiceService#{http://demo.unitedcoders.com/}greetPerson
> has thrown exception, unwinding now
> java.lang.IllegalArgumentException: not an RSA key!
>         at
> org.bouncycastle.jce.provider.JCERSACipher.engineGetKeySize(Unknown
> Source)
>         at javax.crypto.Cipher.b(DashoA13*..)
>         at javax.crypto.Cipher.a(DashoA13*..)
>         at javax.crypto.Cipher.a(DashoA13*..)
>         at javax.crypto.Cipher.a(DashoA13*..)
>         at javax.crypto.Cipher.init(DashoA13*..)
>         at javax.crypto.Cipher.init(DashoA13*..)
>         at
>
> org.apache.ws.security.message.WSSecEncryptedKey.prepareInternal(WSSecEncryptedKey.java:257)
>         at
> org.apache.ws.security.message.WSSecEncrypt.prepare(WSSecEncrypt.java:182)
>         at
> org.apache.ws.security.message.WSSecEncrypt.build(WSSecEncrypt.java:223)
>         at
>
> org.apache.ws.security.action.EncryptionAction.execute(EncryptionAction.java:95)
>         at
> org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:232)
>         at
>
> org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$200(WSS4JOutInterceptor.java:52)
>         at
>
> org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:260)
>         at
>
> org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:136)
>         at
>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
>         at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
>         at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
>         at
> org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
>         at
> org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
>         at com.sun.proxy.$Proxy36.greetPerson(Unknown Source)
>         at
>
> com.unitedcoders.client.PersonServiceClient.main(PersonServiceClient.java:21)
>
> Please help me figure out this issue
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/java-lang-IllegalArgumentException-not-an-RSA-key-at-org-bouncycastle-jce-provider-JCERSACipher-engi-tp5735564.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com