java slow : entropy related issue

前端 未结 2 601
走了就别回头了
走了就别回头了 2021-01-21 05:54

I am running into an issue where java is slow when used over SSL. The solution is to add

-Djava.security.egd=file:/dev/./urandom
to java at the command line. Since I
2条回答
  •  梦毁少年i
    2021-01-21 06:03

    This is actually a hack introduced into the JVM back in 1.3 or 1.4 days

    http://bugs.sun.com/view_bug.do?bug_id=4705093

    http://bugs.sun.com/view_bug.do?bug_id=6202721

    The basic issue is that in the native JVM code they hardcoded /dev/urandom to actually use /dev/random to attempt to ensure sufficient entropy. Since /dev/urandom is supposed to be guaranteed not to block, this has the unintended consequence of blocking if not enough entropy is available.

    The hardcoding looks specifically for the string /dev/urandom, so providing something that resolves to the same thing but doesn't match that causes the desired behavior. If you code /dev/./urandom you bypass the hardcoded aliasing and get to the intended urandom entropy source.

提交回复
热议问题