- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想实现一个小型 android 应用程序,作为 SSL 服务器。在 keystore 的正确格式出现很多问题之后,我解决了这个问题并遇到了下一个问题。
我的 keystore 文件已由 KeyStore 类正确加载。但是当我尝试打开服务器套接字 (socket.accept()) 时,会出现以下错误:
javax.net.ssl.SSLException: Could not find any key store entries to support the enabled cipher suites.
我用这个命令生成了我的 keystore :
keytool -genkey -keystore test.keystore -keyalg RSA -keypass ssltest -storepass ssltest -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath bcprov.jar
将 Java SE6 的无限强度管辖策略应用于我的 jre6。
我通过调用获得了支持的密码套件列表
socket.getSupportedCipherSuites()
打印 long list有非常不同的组合。但我不知道如何获得支持的 key 。在使用 portecle 将其转换为 BKS 格式后,我还尝试了 android 调试 keystore ,但仍然出现相同的错误。
任何人都可以帮助并告诉我如何生成与其中一个密码套件兼容的 key 吗?
版本信息:
targetSDK: 15
在运行 4.0.3 的模拟器和运行 2.3.3 的真实设备上测试
弹跳城堡 1.46
可移植 1.7
我的测试应用程序代码:
public class SSLTestActivity extends Activity implements Runnable {
SSLServerSocket mServerSocket;
ToggleButton tglBtn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.tglBtn = (ToggleButton)findViewById(R.id.toggleButton1);
tglBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
new Thread(SSLTestActivity.this).run();
} else {
try {
if (mServerSocket != null)
mServerSocket.close();
} catch (IOException e) {
Log.e("SSLTestActivity", e.toString());
}
}
}
});
}
@Override
public void run() {
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(getAssets().open("test.keystore"), "ssltest".toCharArray());
ServerSocketFactory socketFactory = SSLServerSocketFactory.getDefault();
mServerSocket = (SSLServerSocket) socketFactory.createServerSocket(8080);
while (!mServerSocket.isClosed()) {
Socket client = mServerSocket.accept();
PrintWriter output = new PrintWriter(client.getOutputStream(), true);
output.println("So long, and thanks for all the fish!");
client.close();
}
} catch (Exception e) {
Log.e("SSLTestActivity", e.toString());
}
}
}
最佳答案
Keystore does not support enabled cipher suites
keystore 是否支持密码套件并不是真正的决定。支持它们的是 SSLSocket
(或引擎)。它正在寻找的是 keystore 中的 key ,该 key 的类型适合其支持的密码套件之一。通常,启用的密码套件是基于 RSA 或 DSS 的,因此它将分别查找 RSA 或 DSA key 。
在下面的代码中:
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(getAssets().open("test.keystore"), "ssltest".toCharArray());
ServerSocketFactory socketFactory = SSLServerSocketFactory.getDefault();
mServerSocket = (SSLServerSocket) socketFactory.createServerSocket(8080);
您没有对您的 keyStore
做任何事情。在这种情况下,您可能根本不加载它(顺便说一下,您应该始终关闭您从中读取的输入流)。
在这里,您仍在使用默认的 SSLServerSocketFactory
,您没有专门配置它(并且没有默认的 keystore ):这就是为什么您得到“Could not find any key store entries to support the enabled cipher suites”:它找不到合适的 key 存储条目,因为它甚至找不到 key 存储。
您需要配置一个 SSLContext
,使用从您的 keystore 构建的 KeyManager
对其进行初始化,然后从中获取一个服务器套接字工厂。
关于java - SSL异常 : Could not find any key store entries to support the enabled cipher suites,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10010126/
我收到多行错误,指出它有重复的类 Duplicate class android.support.v4.accessibilityservice.AccessibilityServiceInfoCom
我的项目昨天运行良好,今天却出现以下错误。请帮忙。 出了什么问题:无法解析配置“:app:debugCompileClasspath”的所有文件。 Could not find support-v4.
错误:配置项目“:app”时出现问题。 Could not find support-v4.jar (com.android.support:support-v4:24.0.0). Searched
我正在使用 react-native-webrtc 运行示例应用程序模块。我正在尝试在 android 中运行该应用程序,但出现这样的错误... * What went wrong: A probl
错误:配置项目“:app”时出现问题。 Could not find support-v4.jar (com.android.support:support-v4:24.0.0). Searched
我克隆了我的项目并使用 Android studio 打开,但构建失败并出现以下错误并且同一个项目在其他项目上运行良好。 出了什么问题:无法解析配置“:app:flavorUnsignedReleas
我正在运行示例应用程序......我正在使用 this模块.....但是我收到这样的错误... FAILURE: Build failed with an exception. * What went
我有一个 Ionic 项目,在升级到 OSx Mojave 后,出于某种原因不再构建。 该项目基于 Ionic 3 构建。 我有 Cordova CLI 7.0.0 当我运行时 ionic cordo
我有一个 Ionic 项目,在升级到 OSx Mojave 后,出于某种原因不再构建。 该项目基于 Ionic 3 构建。 我有 Cordova CLI 7.0.0 当我运行时 ionic cordo
添加 Android 平台(ionic cordova platform add android)后,我构建了我的 Ionic 项目(ionic cordova build android),但出现错
这个问题在这里已经有了答案: Manifest merger failed : Attribute application@appComponentFactory - Androidx (14 个答
关于我的 Gradle 文件中的以下“complie”: dependencies { compile 'com.android.support:support-v4:25.3.1' }
有些困惑。 我想更频繁地使用@supports 但是...我不关心浏览器如何看待它。希望您能说清楚,如果可以的话谢谢您。 如果浏览器本身不理解@supports,它如何计算@support 'not'
我刚刚升级到 Dart 2 和最新版本的 Flutter,现在我无法构建我的应用程序。我在互联网上环顾四周,但仍然不明白为什么会发生这种情况。 我得到的错误是: FAILURE: Build fail
我正在学习 Firebase,但由于以下错误而陷入困境: Error:Failed to resolve: com.android.support:customtabs:25.4.0 Error:Fa
我在构建本周时出于某种原因尝试使用Cordova进行项目时遇到问题: cordova build android gradle获取com.android.support:support alpha而不
对应的androidx是什么com.android.support:support-compat 的图书馆实现push notifications ? 他们说here它是 androidx 的一部分,
我正在尝试为我的应用设置插桩单元测试。并且我已根据以下开发者站点链接添加了依赖项。 https://developer.android.com/training/testing/unit-testin
当我想使用 Proguard 规则生成签名的 APK(发布)时,我收到了以下错误消息: Cannot find a version of 'com.android.support:support-an
这个问题在这里已经有了答案: Failed to resolve: com.android.support:appcompat-v7:26.0.0 (14 个答案) Failed to resolv
我是一名优秀的程序员,十分优秀!