相互认证 Android 和 Tomcat
Mutual authentication Android and Tomcat
我想为我的应用程序和服务器进行相互授权。
我按照这个步骤:
1) 创建证书。和服务器的密钥库 tomcat (tomcat.keystore)
2) 创建证书。为客户
3) 导入客户端证书。进入服务器密钥库
4) 为 Android (smartssl.bks)
创建一个 bks 密钥库
5) 导入证书。服务器和客户端进入密钥库 Android
现在我将 Tomcat 配置为:
<Connector SSLEnabled="true" clientAuth="true"
keystoreFile="/home/antonio/Documenti/keystore/tomcat.keystore"
keystorePass="pass" maxThreads="150" port="8443" scheme="https"
secure="true" sslProtocol="TLS"
truststoreFile="/home/antonio/Documenti/keystore/tomcat.keystore"
truststorePass="pass" />
在 Android 应用程序中,我使用了这样的 Volley 框架:
InputStream keyStore = getResources().openRawResource(R.raw.smartssl);
// Usually getting the request queue shall be in singleton like in {@see Act_SimpleRequest}
// Current approach is used just for brevity
RequestQueue queue = Volley
.newRequestQueue(Act_SsSslHttpClient.this,
new ExtHttpClientStack(new SslHttpClient(keyStore, "pass", 443)));
StringRequest myReq = new StringRequest(Method.GET,
"https://192.168.1.4:8443/REST/app/generali/getA",
createMyReqSuccessListener(),
createMyReqErrorListener()){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return createBasicAuthHeader("user", "strongpassword");
}};
queue.add(myReq);
}
});
有了这个配置。我有这个错误:
no peer certificate
如果我尝试用这个更改 Tomcat 配置:
clientAuth="false"
有效,所以问题出在 bks 文件中?或者在哪里?
我通过在应用程序中放入 BKS 中的 Keystore 和 Truststore 来解决。
这里有一个创建自我证书的指南:
Create a self certificate for client and server
这里有 class 与 Volley 相互验证的示例:
我想为我的应用程序和服务器进行相互授权。 我按照这个步骤:
1) 创建证书。和服务器的密钥库 tomcat (tomcat.keystore)
2) 创建证书。为客户
3) 导入客户端证书。进入服务器密钥库
4) 为 Android (smartssl.bks)
创建一个 bks 密钥库5) 导入证书。服务器和客户端进入密钥库 Android
现在我将 Tomcat 配置为:
<Connector SSLEnabled="true" clientAuth="true"
keystoreFile="/home/antonio/Documenti/keystore/tomcat.keystore"
keystorePass="pass" maxThreads="150" port="8443" scheme="https"
secure="true" sslProtocol="TLS"
truststoreFile="/home/antonio/Documenti/keystore/tomcat.keystore"
truststorePass="pass" />
在 Android 应用程序中,我使用了这样的 Volley 框架:
InputStream keyStore = getResources().openRawResource(R.raw.smartssl);
// Usually getting the request queue shall be in singleton like in {@see Act_SimpleRequest}
// Current approach is used just for brevity
RequestQueue queue = Volley
.newRequestQueue(Act_SsSslHttpClient.this,
new ExtHttpClientStack(new SslHttpClient(keyStore, "pass", 443)));
StringRequest myReq = new StringRequest(Method.GET,
"https://192.168.1.4:8443/REST/app/generali/getA",
createMyReqSuccessListener(),
createMyReqErrorListener()){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return createBasicAuthHeader("user", "strongpassword");
}};
queue.add(myReq);
}
});
有了这个配置。我有这个错误:
no peer certificate
如果我尝试用这个更改 Tomcat 配置:
clientAuth="false"
有效,所以问题出在 bks 文件中?或者在哪里?
我通过在应用程序中放入 BKS 中的 Keystore 和 Truststore 来解决。
这里有一个创建自我证书的指南:
Create a self certificate for client and server
这里有 class 与 Volley 相互验证的示例: