我已经在我的项目中实现了叶子证书,它工作正常。请检查以下代码,现在问题是叶子证书将在我的服务器中一年后过期,所以我想验证叶子证书,以便当它过期/无效时我可以使用中间证书吗?
是否有任何示例来实施中间证书?
请帮助我!
代码: -
SSLContext sslContext = null;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream caInput = context.getResources().openRawResource(certRawRef);
Certificate ca;
try {
ca = cf.generateCertificate(caInput);
} finally {
caInput.close();
}
// Create a KeyStore containing our trusted CAs
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", ca);
// Create a TrustManager that trusts the CAs in our KeyStore
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
tmf.init(keyStore);
// Create an SSLContext that uses our TrustManager
sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, tmf.getTrustManagers(), null);
return sslContext;
} catch (Exception e) {
Log.e("EXCEPTION",e.toString());
//Print here right certificate failure issue
}
答案 0 :(得分:1)
最后我找到了答案: -
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border="1">
<tr>
<td id="1">One <a href="javascript:void(0);" class="edit">Edit</a></td>
</tr>
<tr>
<td id="2">Two <a href="javascript:void(0);" class="edit">Edit</a></td>
</tr>
<tr>
<td id="3">Three <a href="javascript:void(0);" class="edit">Edit</a></td>
</tr>
</table>