<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://brokenco.de//feed/by_tag/java.xml" rel="self" type="application/atom+xml" /><link href="https://brokenco.de//" rel="alternate" type="text/html" /><updated>2026-08-24T11:29:18+00:00</updated><id>https://brokenco.de//feed/by_tag/java.xml</id><title type="html">rtyler</title><subtitle>a moderately technical blog</subtitle><author><name>R. Tyler Croy</name></author><entry><title type="html">JKS? jfc. Adding a root certificate</title><link href="https://brokenco.de//2019/09/28/jks-jfc.html" rel="alternate" type="text/html" title="JKS? jfc. Adding a root certificate" /><published>2019-09-28T00:00:00+00:00</published><updated>2019-09-28T00:00:00+00:00</updated><id>https://brokenco.de//2019/09/28/jks-jfc</id><content type="html" xml:base="https://brokenco.de//2019/09/28/jks-jfc.html"><![CDATA[<p>TLS certificates have the largest “complexity/importance” scores imaginable.
Everything about them is error prone and seemingly over-engineered from top to
bottom, yet they are one of the most important pieces of security and
authentication in our software architectures. From an engineering management
standpoint, I am finding myself adopting the rule of: estimates for any project
involving certificates should be multiplied tenfold. If the project involves
the Java Virtual Machine (JVM) and the Java Key Store (JKS), multiply by
another ten I suppose. For my own future convenience, in this blog post I would
like to outline how to add a root certificate to a Java Key Store in Red
Hat-derived environments.</p>

<p>Like many corporate environments, we have our own internal Certificate
Authorities (CAs) which all derive their chain of trust from our internal root
certificate. Accessing internal services requires that the operating system has
that root certificate, or when accessing those internal services from anything
running atop the JVM, the default JKS must have the root certificate.</p>

<p>If you search around the web for how to add root certificates, you might find
the <code class="language-plaintext highlighter-rouge">update-ca-certificates</code> command, whose CentOS/RHEl manpage has the
following:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>The directory /etc/pki/ca-trust/extracted/java/ contains a CA
certificate bundle in the java keystore file format. Distrust information
cannot be represented in this file format, and distrusted certificates are
missing from these files. File cacerts contains CA certificates trusted for TLS
server authentication.
</code></pre></div></div>

<p>You might assume, as I did, that this means the <code class="language-plaintext highlighter-rouge">update-ca-certificates</code> tool
is going to create files that the JVM picks up properly and your default JKS
will have the root certificate in place.</p>

<p>This is <em>false</em>. At least in the environments which I have tested this.</p>

<p>Digging further I found <a href="https://connect2id.com/blog/importing-ca-root-cert-into-jvm-trust-store">this blog post</a> and used the following command to import the root certificate into JKS after installing it on the system at large:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>keytool -importcert -alias startssl -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -file ca.der
</code></pre></div></div>

<p>Using the SSLPoke tool referenced in <a href="https://confluence.atlassian.com/kb/unable-to-connect-to-ssl-services-due-to-pkix-path-building-failed-779355358.html">this Atlassian knowledgebase
article</a>
I was then <em>finally</em> able to access the same internal services from native
utilities (e.g. <code class="language-plaintext highlighter-rouge">curl</code>) and from the Java-based services which I was working
with at the time.</p>

<p>In my situation, the fact that all of this was happening within Docker
containers further complicated the debugging: multiple by another 2-5 on that
engineering estimate.</p>

<p>Certificates are too important to be this painful.</p>]]></content><author><name>R. Tyler Croy</name></author><category term="security" /><category term="tls" /><category term="java" /><category term="scribd" /><summary type="html"><![CDATA[TLS certificates have the largest “complexity/importance” scores imaginable. Everything about them is error prone and seemingly over-engineered from top to bottom, yet they are one of the most important pieces of security and authentication in our software architectures. From an engineering management standpoint, I am finding myself adopting the rule of: estimates for any project involving certificates should be multiplied tenfold. If the project involves the Java Virtual Machine (JVM) and the Java Key Store (JKS), multiply by another ten I suppose. For my own future convenience, in this blog post I would like to outline how to add a root certificate to a Java Key Store in Red Hat-derived environments.]]></summary></entry></feed>