⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 certpathexample.java

📁 sip CMSEnvelopedData
💻 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 + -