Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creation of SecureRandom is slow, even in java 8

I searched on this problem. I got impression, it is resolved in java 8. But suddenly, I started getting this problem in my new VM, based of ubuntu 14.04.

2015-07-27 14:56:35.324 INFO 11809 --- [localhost-startStop-1] o.a.c.util.SessionIdGeneratorBase : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [167,833] milliseconds.

And java version is

java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Server is ubuntu 14.04.

Another thing is, i running this java process as spring boot application, which has embedded tomcat running.

Any ideas, what could be wrong? I even tried,

-Djava.security.egd=file:/dev/./urandom option

like image 521
Ashish Jain Avatar asked Jul 27 '15 19:07

Ashish Jain


2 Answers

Try using the following command while running

java -Djava.security.egd=file:/dev/./urandom -jar demo.jar

like image 159
KarthiG Avatar answered Nov 10 '22 11:11

KarthiG


Try replacing embedded tomcat with undertow, by pasting the snippet below into your pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
    <version>2.1.0.RELEASE</version>
</dependency>

It works for me perfectly. SecureRandom issue is a tomcat issue which you can totally replace with another servlet container.

like image 43
Julius Delfino Avatar answered Nov 10 '22 09:11

Julius Delfino