<?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>SAML &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/saml/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 16:36:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>SAML &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Java + SAML: Illegal Key Size</title>
		<link>https://myshittycode.com/2016/02/18/java-saml-illegal-key-size/</link>
					<comments>https://myshittycode.com/2016/02/18/java-saml-illegal-key-size/#comments</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Thu, 18 Feb 2016 19:24:00 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SAML]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=900</guid>

					<description><![CDATA[<p>PROBLEM When attempting to decrypt the SAML response from IdP, the following exception occurs:- SOLUTION When inspecting the SAML response payload below, the data is encrypted with AES-256:- By default, Java&#8217;s keysize is limited to 128-bit key due to US export laws and a few countries&#8217; import laws. To fix this&#8230;</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2016/02/18/java-saml-illegal-key-size/">Java + SAML: Illegal Key Size</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>When attempting to decrypt the SAML response from IdP, the following exception occurs:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size
Original Exception was java.security.InvalidKeyException: Illegal key size
	at org.apache.xml.security.encryption.XMLCipher.decryptToByteArray(XMLCipher.java:1822)
	at org.opensaml.xml.encryption.Decrypter.decryptDataToDOM(Decrypter.java:596)
	at org.opensaml.xml.encryption.Decrypter.decryptUsingResolvedEncryptedKey(Decrypter.java:795)
	at org.opensaml.xml.encryption.Decrypter.decryptDataToDOM(Decrypter.java:535)
	at org.opensaml.xml.encryption.Decrypter.decryptDataToList(Decrypter.java:453)
	at org.opensaml.xml.encryption.Decrypter.decryptData(Decrypter.java:414)
	at org.opensaml.saml2.encryption.Decrypter.decryptData(Decrypter.java:141)
	at org.opensaml.saml2.encryption.Decrypter.decrypt(Decrypter.java:69)
	at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:199)
	at org.springframework.security.saml.SAMLAuthenticationProvider.authenticate(SAMLAuthenticationProvider.java:82)
</pre></div>


<h2 class="wp-block-heading">SOLUTION</h2>



<p>When inspecting the SAML response payload below, the data is encrypted with AES-256:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; highlight: [14]; title: ; notranslate">
&amp;lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?--&gt;
&amp;lt;samlp:response consent=&quot;urn:oasis:names:tc:SAML:2.0:consent:unspecified&quot; destination=&quot;https://server/my-app/saml/SSO&quot; id=&quot;_370d6ba5-177c-494b-9147-2eafd9ecb6c9&quot; inresponseto=&quot;a5c5dja1i5fgb2bf2e66f6g9g5398gj&quot; issueinstant=&quot;2016-02-18T15:28:43.473Z&quot; version=&quot;2.0&quot; xmlns:samlp=&quot;urn:oasis:names:tc:SAML:2.0:protocol&quot;&gt;
    &amp;lt;issuer xmlns=&quot;urn:oasis:names:tc:SAML:2.0:assertion&quot;&gt;http://adfs-server/adfs/services/trust&amp;lt;/issuer&gt;
    &amp;lt;samlp:status&gt;
        &amp;lt;samlp:statuscode value=&quot;urn:oasis:names:tc:SAML:2.0:status:Success&quot;&gt;
    &amp;lt;/samlp:statuscode&gt;&amp;lt;/samlp:status&gt;
    &amp;lt;encryptedassertion xmlns=&quot;urn:oasis:names:tc:SAML:2.0:assertion&quot;&gt;
        &amp;lt;xenc:encrypteddata type=&quot;http://www.w3.org/2001/04/xmlenc#Element&quot; xmlns:xenc=&quot;http://www.w3.org/2001/04/xmlenc#&quot;&gt;
            &amp;lt;xenc:encryptionmethod algorithm=&quot;http://www.w3.org/2001/04/xmlenc#aes256-cbc&quot;&gt;
            &amp;lt;keyinfo xmlns=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt;
                &amp;lt;e:encryptedkey xmlns:e=&quot;http://www.w3.org/2001/04/xmlenc#&quot;&gt;
                    &amp;lt;e:encryptionmethod algorithm=&quot;http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p&quot;&gt;
                        &amp;lt;digestmethod algorithm=&quot;http://www.w3.org/2000/09/xmldsig#sha1&quot;&gt;
                    &amp;lt;/digestmethod&gt;&amp;lt;/e:encryptionmethod&gt;
                    &amp;lt;keyinfo&gt;
                        &amp;lt;ds:x509data xmlns:ds=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt;
                            &amp;lt;ds:x509issuerserial&gt;
                                &amp;lt;ds:x509issuername&gt;CN=server&amp;lt;/ds:x509issuername&gt;
                                &amp;lt;ds:x509serialnumber&gt;1822784706&amp;lt;/ds:x509serialnumber&gt;
                            &amp;lt;/ds:x509issuerserial&gt;
                        &amp;lt;/ds:x509data&gt;
                    &amp;lt;/keyinfo&gt;
                    &amp;lt;e:cipherdata&gt;
                        &amp;lt;e:ciphervalue&gt;isG83fVk50fJRIcg...&amp;lt;/e:ciphervalue&gt;
                    &amp;lt;/e:cipherdata&gt;
                &amp;lt;/e:encryptedkey&gt;
            &amp;lt;/keyinfo&gt;
            &amp;lt;xenc:cipherdata&gt;
                &amp;lt;xenc:ciphervalue&gt;+b2o6HNxaxsse7rkB...&amp;lt;/xenc:ciphervalue&gt;
            &amp;lt;/xenc:cipherdata&gt;
        &amp;lt;/xenc:encryptionmethod&gt;&amp;lt;/xenc:encrypteddata&gt;
    &amp;lt;/encryptedassertion&gt;
&amp;lt;/samlp:response&gt;
</pre></div>


<p>By default, Java&#8217;s keysize is limited to 128-bit key due to US export laws and a few countries&#8217; import laws.</p>



<p>To fix this&#8230;</p>



<ul class="wp-block-list">
<li>Determine the Java version.</li>



<li>Download Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files &#8211; <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html" target="_blank" rel="noopener">Java 7</a> or <a href="http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html" target="_blank" rel="noopener">Java 8</a>.</li>



<li>Inflate the zip file.</li>



<li>Copy <b>local_policy.jar</b> and <b>US_export_policy.jar</b> to <b>[JAVA_HOME]/jre/lib/security</b>.</li>
</ul>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2016/02/18/java-saml-illegal-key-size/">Java + SAML: Illegal Key Size</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2016/02/18/java-saml-illegal-key-size/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">900</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-20 06:58:25 by W3 Total Cache
-->