SSL/TLS 动态密钥生成
SSL/TLS dynamic key generation
在我的这个项目中,我需要在客户端和服务器之间使用 SSL/TLS 实现安全连接。我找到了一篇很好的文章,所以我成功地完成了我的任务。
我的问题很简单,但我找不到任何答案。在这种特殊情况下,我的客户在 SSL 协议中具有相同的密钥,该密钥是通过先前 link 上的教程创建的,并放入某种文件中。此过程中的潜在问题是有人可以访问该文件,并且由于每个客户端都有该密钥,因此有人可以侦听所有连接。
我想问的是,有没有机会在每次客户端想要访问服务器时动态生成密钥并将生成的密钥放入服务器信任库中?
更新
public static final String PATH_TO_ANDROID_KEYSTORE = "and/client.bks";
public static final String PATH_TO_ANDROID_TRUSTSTORE = "and/clienttruststore.bks";
String pathToKeyStore = PATH_TO_ANDROID_KEYSTORE;
String pathToTrustStore = PATH_TO_ANDROID_TRUSTSTORE;
KeyStore keyStoreKeys = KeyStore.getInstance(keyStoreType);
keyStoreKeys.load(Gdx.files.internal(pathToKeyStore).read(), passphrase);
KeyStore keyStoreTrust = KeyStore.getInstance(keyStoreType);
keyStoreTrust.load(Gdx.files.internal(pathToTrustStore).read(), passphrase);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStoreKeys, passphrase);
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStoreTrust);
这是客户端代码,看起来客户端已经在他们的信任库中导出了服务器的证书,但他们实际上使用的是使用 openssl 工具在密钥库中仅生成一次的相同私钥。
In this particular case, my clients have the same key in the SSL protocol which is created through tutorial on a previous link and put in some kind of a file.
不清楚。您是说他们共享相同的 private 密钥吗?如果是这样,那是您的系统设计中的缺陷。每个客户端都应该有自己的私钥。否则私钥就不是,呃,私密的。并且应该通过密钥库访问该密钥,其密码只有应用程序知道,这至少提供了另一道防线。
如果您的意思是他们都在他们的 truststores 中拥有服务器 证书 的导出副本,则没有安全风险完全依附于此:这是完全正常的。
Potential problem in this process is that someone can access that file and since every client has that key, someone can listen to all connections.
不,他们不能。如果您不破坏 服务器的 私钥,SSL 就不会受到中间人攻击,但如果您谈论的是客户端私钥,它们可以伪装成真正的客户端即使他们不是,if 他们也可以突破密钥库密码障碍。
What I wanted to ask, is there any chance to dynamically generate keys every time some client wants to access the server and put the generated key in the server truststore?
不安全,也不在线。如果您的真正客户可以做到,那么攻击者也可以。这就是信任 material 必须离线分发的原因。
在我的这个项目中,我需要在客户端和服务器之间使用 SSL/TLS 实现安全连接。我找到了一篇很好的文章,所以我成功地完成了我的任务。
我的问题很简单,但我找不到任何答案。在这种特殊情况下,我的客户在 SSL 协议中具有相同的密钥,该密钥是通过先前 link 上的教程创建的,并放入某种文件中。此过程中的潜在问题是有人可以访问该文件,并且由于每个客户端都有该密钥,因此有人可以侦听所有连接。
我想问的是,有没有机会在每次客户端想要访问服务器时动态生成密钥并将生成的密钥放入服务器信任库中?
更新
public static final String PATH_TO_ANDROID_KEYSTORE = "and/client.bks";
public static final String PATH_TO_ANDROID_TRUSTSTORE = "and/clienttruststore.bks";
String pathToKeyStore = PATH_TO_ANDROID_KEYSTORE;
String pathToTrustStore = PATH_TO_ANDROID_TRUSTSTORE;
KeyStore keyStoreKeys = KeyStore.getInstance(keyStoreType);
keyStoreKeys.load(Gdx.files.internal(pathToKeyStore).read(), passphrase);
KeyStore keyStoreTrust = KeyStore.getInstance(keyStoreType);
keyStoreTrust.load(Gdx.files.internal(pathToTrustStore).read(), passphrase);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStoreKeys, passphrase);
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStoreTrust);
这是客户端代码,看起来客户端已经在他们的信任库中导出了服务器的证书,但他们实际上使用的是使用 openssl 工具在密钥库中仅生成一次的相同私钥。
In this particular case, my clients have the same key in the SSL protocol which is created through tutorial on a previous link and put in some kind of a file.
不清楚。您是说他们共享相同的 private 密钥吗?如果是这样,那是您的系统设计中的缺陷。每个客户端都应该有自己的私钥。否则私钥就不是,呃,私密的。并且应该通过密钥库访问该密钥,其密码只有应用程序知道,这至少提供了另一道防线。
如果您的意思是他们都在他们的 truststores 中拥有服务器 证书 的导出副本,则没有安全风险完全依附于此:这是完全正常的。
Potential problem in this process is that someone can access that file and since every client has that key, someone can listen to all connections.
不,他们不能。如果您不破坏 服务器的 私钥,SSL 就不会受到中间人攻击,但如果您谈论的是客户端私钥,它们可以伪装成真正的客户端即使他们不是,if 他们也可以突破密钥库密码障碍。
What I wanted to ask, is there any chance to dynamically generate keys every time some client wants to access the server and put the generated key in the server truststore?
不安全,也不在线。如果您的真正客户可以做到,那么攻击者也可以。这就是信任 material 必须离线分发的原因。