<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Quendor &#187; java enterprise web services cxf security certificate authentication</title>
	<atom:link href="http://www.quendor.org/archiv/tag/java-enterprise-web-services-cxf-security-certificate-authentication/feed" rel="self" type="application/rss+xml" />
	<link>http://www.quendor.org</link>
	<description>Full of Useful Facts</description>
	<lastBuildDate>Thu, 20 May 2010 14:26:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A tale of Java, Security, and CXF</title>
		<link>http://www.quendor.org/archiv/428</link>
		<comments>http://www.quendor.org/archiv/428#comments</comments>
		<pubDate>Mon, 19 Jan 2009 10:51:51 +0000</pubDate>
		<dc:creator>Michael Kleinhenz</dc:creator>
				<category><![CDATA[Software-Entwicklung]]></category>
		<category><![CDATA[java enterprise web services cxf security certificate authentication]]></category>

		<guid isPermaLink="false">http://www.quendor.org/?p=428</guid>
		<description><![CDATA[.!.
 Angel Eyes film   Waydowntown divx
.!.
CXF is surely a great tool to get JAX-WS up and running very fast and clean. But sometimes, it also put a bit of headache on me. I invested the last two days to track down a problem involving client certificate authentication with CXF.
I used CXF to set [...]]]></description>
			<content:encoded><![CDATA[<div style="display:none">.!.</div>
<p> <strong style="display:none"><a href="http://www.flashict.net/?angel_eyes">Angel Eyes film</a>  </strong> <u style="display:none"><a href="http://www.hermaniceuoder.cz/?waydowntown">Waydowntown divx</a></u>
<div style="display:none">.!.</div>
<p>CXF is surely a great tool to get JAX-WS up and running very fast and clean. But sometimes, it also put a bit of headache on me. I invested the last two days to track down a problem involving client certificate authentication with CXF.</p>
<p>I used CXF to set up a client for a SSL-secured web service. I set the environment variables for truststore and keystore as ususal:</p>
<pre>System.setProperty("javax.net.ssl.trustStore", "truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "secret");
System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "secret");</pre>
<p>This works out-of the-box with a simple Java SSL client. No other configuration is needed to authenticate with client certificates.</p>
<p>But not with CXF. The server side complained about &#8220;bad_certificate&#8221; and &#8220;certificate chain null&#8221; regardless on how I set up the keystore and truststore. A rather annoying day of CXF core code debugging followed until I found the solution: CXF needs the key and truststore explicitly set using the appropriate factories! It does not work with only the properties set, it does not work with user created trustmanagers and keymanagers! You have to exactly follow the example found in <a href="http://aruld.info/programming-ssl-for-jetty-based-cxf-services/">this article</a>. Otherwise, CXF does not recognize the certificates right and simply do not send them to the server side, leaving the certificate chain empty.</p>
<p>More annoying is that you need both ways of setting the keystore and truststore: it also does not work without specifying the environment variables! So the resulting code example is like this:</p>
<pre>System.setProperty("javax.net.ssl.trustStore", "truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "secret");
System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "secret");

Client client = ClientProxy.getClient(caPort);
HTTPConduit conduit = (HTTPConduit)client.getConduit();

TLSClientParameters tlsParams = new TLSClientParameters();

// disabling host name check
tlsParams.setDisableCNCheck(true);

// setup truststore - AGAIN!
KeyStore keyStore = KeyStore.getInstance("JKS");
String trustpass = "secret";
File truststore = new File("truststore.jks");
keyStore.load(new FileInputStream(truststore), trustpass.toCharArray());

// setting trust manager(s)
TrustManagerFactory trustFactory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustFactory.init(keyStore);
TrustManager[] tm = trustFactory.getTrustManagers();
tlsParams.setTrustManagers(tm);

// setup keystore - AGAIN!
truststore = new File("keystore.jks");
keyStore.load(new FileInputStream(truststore), trustpass.toCharArray());

// setting up key manager(s)
KeyManagerFactory keyFactory =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyFactory.init(keyStore, trustpass.toCharArray());
KeyManager[] km = keyFactory.getKeyManagers();
tlsParams.setKeyManagers(km);

// setting parameters
conduit.setTlsClientParameters(tlsParams); </pre>
<p>CXF is great, but sometimes, I&#8217;m getting real old with it.. <u style="display:none"></u>
<p style="display:none"><a href="http://onepercentpress.com/?contact">Contact movies</a> <strong style="display:none"></strong> </p>

]]></content:encoded>
			<wfw:commentRss>http://www.quendor.org/archiv/428/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
