问题描述
我正在尝试使用Apache Commons Crypto库。我正在使用来自Apache官方站点的示例代码来使用此库的Random API。 这是指向它的链接-https://commons.apache.org/proper/commons-crypto/xref-test/org/apache/commons/crypto/examples/RandomExample.html
使用方法getCryptoRandom时出现此异常。
Exception in thread "main" java.security.GeneralSecurityException: CryptoRandom: [org.apache.commons.crypto.random.OpenSslCryptoRandom] failed with java.lang.reflect.InvocationTargetException
at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:217)
at com.nix.apps.crypto.Main.main(Main.java:25)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.commons.crypto.utils.ReflectionUtils.newInstance(ReflectionUtils.java:90)
at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:198)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.commons.crypto.utils.ReflectionUtils.newInstance(ReflectionUtils.java:88)
... 2 more
Caused by: java.security.GeneralSecurityException: Native library could not be initialised
at org.apache.commons.crypto.random.OpenSslCryptoRandom.<init>(OpenSslCryptoRandom.java:88)
... 7 more
Caused by: java.lang.UnsatisfiedLinkError: ENGINE_load_rdrand
at org.apache.commons.crypto.random.OpenSslCryptoRandomNative.initSR(Native Method)
at org.apache.commons.crypto.random.OpenSslCryptoRandom.<clinit>(OpenSslCryptoRandom.java:56)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.commons.crypto.utils.ReflectionUtils.getClassByNameOrNull(ReflectionUtils.java:138)
at org.apache.commons.crypto.utils.ReflectionUtils.getClassByName(ReflectionUtils.java:103)
at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:197)
... 1 more
以退出代码1完成的过程
如何解决此问题?
据我了解,问题在于加载openSSL引擎或类似的东西:
Caused by: java.lang.UnsatisfiedLinkError: ENGINE_load_rdrand
at org.apache.commons.crypto.random.OpenSslCryptoRandomNative.initSR(Native Method)
at org.apache.commons.crypto.random.OpenSslCryptoRandom.<clinit>(OpenSslCryptoRandom.java:56)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.commons.crypto.utils.ReflectionUtils.getClassByNameOrNull(ReflectionUtils.java:138)
at org.apache.commons.crypto.utils.ReflectionUtils.getClassByName(ReflectionUtils.java:103)
at org.apache.commons.crypto.random.CryptoRandomFactory.getCryptoRandom(CryptoRandomFactory.java:197)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)