申请证书时生成的req文件需要:主题 密钥对 签名加密算法
写道
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.SignatureException;
import javax.security.auth.x500.X500Principal;
import sun.misc.BASE64Encoder;
/**
* @param algorithm签名算法 1.SHA1withRSA 2.SM3WITHSM2
* @param dn主题
* @param keyPair密钥对
* @param keyType密钥类型 SM2|RSA
* @return 返回p10请求的字符串
* @throws SignatureException
* @throws NoSuchProviderException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws KeyPairException
*/
private static String getP10ReqestBC(String algorithm, String dn, KeyPair keyPair,String keyType) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException
{
String p10RequestString = null;
byte[] p10buffer = null;
if(keyTy
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.SignatureException;
import javax.security.auth.x500.X500Principal;
import sun.misc.BASE64Encoder;
/**
* @param algorithm签名算法 1.SHA1withRSA 2.SM3WITHSM2
* @param dn主题
* @param keyPair密钥对
* @param keyType密钥类型 SM2|RSA
* @return 返回p10请求的字符串
* @throws SignatureException
* @throws NoSuchProviderException
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
* @throws KeyPairException
*/
private static String getP10ReqestBC(String algorithm, String dn, KeyPair keyPair,String keyType) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException
{
String p10RequestString = null;
byte[] p10buffer = null;
if(keyTy