gpt4 book ai didi

java.security.NoSuchProviderException : no such provider: SUN

转载 作者:行者123 更新时间:2023-11-30 06:47:11 33 4
gpt4 key购买 nike

我已经使用二维码实现了双重身份验证。我已经使用 GoogleAuth 完成了它图书馆。在我的本地环境中运行起来非常棒,但是当我在 WebSphere 8.5.5 上部署应用程序时,它会抛出此错误:

java.security.NoSuchProviderException: no such provider: SUN

并且 GoogleAuth 抛出这个异常:

Could not initialise SecureRandom with the specified provider: SUN. 
Another provider can be chosen setting the com.warrenstrange.googleauth.rng.algorithmProvider system property

关于这个方法:

private String getRandomNumberAlgorithm()
{
return System.getProperty(RNG_ALGORITHM, DEFAULT_RANDOM_NUMBER_ALGORITHM);
}

我找到了这个 issue在与我的问题非常相似的项目的 GitHub 页面上,编写这个库的人在这里解释了这个方法的作用:

The library currently gets a SecureRandom instance using the SecureRandom#getInstance method and specifying the SHA1PRNG algorithm and the SUN provider

我知道我必须使用 System.setProperty("com.warrenstrange.googleauth.rng.algorithmProvider", "property") 用另一个提供程序覆盖 SUN ,因为系统找不到它,但我不明白为什么会抛出异常。在我的机器上,我使用 Java 7 运行应用程序,而 Websphere 使用相同的版本。不同之处在于,在 WebSphere 上运行的应用程序是使用 Java 6 编译的。

我的问题是:

为什么会抛出这个异常? SUN 提供程序不是 Java 的一部分吗?

我应该使用哪些其他提供商以及如何使用?

最佳答案

不同之处在于 SUN 提供程序在某些 WebSphere/Java 版本中默认不可用。您可以检查它是否存在于 WebSphere/AppServer/java/jre/lib/security 目录中的 java.security 文件中。

通过该属性将 IBMJCE 指定为提供者以使用它而不是 SUN

关于java.security.NoSuchProviderException : no such provider: SUN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46279117/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com