📄 certpathexample.java
字号:
package chapter6;
import java.io.ByteArrayInputStream;
import java.security.cert.CertPath;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;
/**
* Basic example of creating and encoding a CertPath.
*/
public class CertPathExample
{
public static void main(
String[] args)
throws Exception
{
X509Certificate[] chain = PKCS10CertCreateExample.buildChain();
// create the factory and path object
CertificateFactory fact = CertificateFactory.getInstance("X.509", "BC");
CertPath certPath = fact.generateCertPath(Arrays.asList(chain));
byte[] encoded = certPath.getEncoded("PEM");
System.out.println(Utils.toString(encoded));
// re-read the CertPath
CertPath newCertPath = fact.generateCertPath(new ByteArrayInputStream(encoded), "PEM");
if (newCertPath.equals(certPath))
{
System.out.println("CertPath recovered correctly");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -