Slow SecureRandom initialization : <p>Suppose you do simple thing:</p>

<pre><code>public class Main {
    public static void main(String[] args) {
        long started = System.currentTimeMillis();
        try {
            new URL(args[0]).openConnection();
        } catch (Exception ignore) {
        }
        System.out.println(System.currentTimeMillis() - started);
    }
}
</code></pre>

<p>Now run it with <a href="http://localhost" rel="noreferrer">http://localhost</a> as <code>args[0]</code></p>

<p>It takes <code>~100 msec</code> to complete.</p>

<p>Now try <a href="https://localhost" rel="noreferrer">https://localhost</a></p>

<p>It takes <code>5000+ msec</code>. </p>

<p>Now run the same thing on linux or in docker:</p>

<ul>
<li>http: <code>~100 msec</code></li>
<li>https: <code>~350 msec</code></li>
</ul>

<p>Why is this?
Why such a huge difference between platforms?
What can you do about it?</p>

<p>For long-running application servers and applications with their own long and heavy initialization sequence, these 5 seconds may not matter.</p>

<p>However, there are plenty of applications where this initial 5sec "hang" matters and may become frustrating...</p>
