123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package com.caimei.modules.order.utils;
- import org.bouncycastle.jce.provider.BouncyCastleProvider;
- import java.security.PrivateKey;
- import java.security.PublicKey;
- import java.security.Security;
- public class HeliPayCertConfig {
- /**
- * 证书存储路径
- */
- private static final String CERT_PATH = "key\\dev\\";
- //private static final String CERT_PATH = "D:\\certs\\key\\dev\\";
- /**
- * 商户SM2证书私钥路径
- */
- private static final String MERCHANT_PRIVATE_KEY_PATH = CERT_PATH + "C1800000002_dev.pfx";
- /**
- * 商户SM2证书私钥密码
- */
- private static final String MERCHANT_PRIVATE_KEY_PWD = "123456";
- /**
- * 商户SM2证书私钥字符串
- */
- private static final PrivateKey merchantPrivateKey;
- /**
- * 合利宝SM2证书公钥路径
- */
- private static final String HELIPAY_PUBLIC_KEY_PATH = CERT_PATH + "helipay_pub_dev.cer";//取决支付系统加载的合利宝私钥配对
- //加密机公钥证书
- //private static final String HELIPAY_PUBLIC_KEY_PATH = "D:\\certs\\hsm\\helipay-hsm.cer";
- /**
- * 合利宝SM2证书公钥对象
- */
- private static final PublicKey helipayPublicKey;
- static {
- if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
- Security.addProvider(new BouncyCastleProvider());
- }
- try {
- merchantPrivateKey = HeliPayCertUtils.getPrivateKeyByPfx("/mnt/newdatadrive/keys/C1806995267_2303010060964109_privateKey.pfx","cm20230327");
- } catch (Exception e) {
- throw new RuntimeException("获取SM2证书私钥字符串异常:"+e.getMessage(),e) ;
- }
- try {
- helipayPublicKey = HeliPayCertUtils.getPublicKey("/mnt/newdatadrive/keys/helipayPublicKey.cer");
- } catch (Exception e) {
- throw new RuntimeException("加载合利宝SM2证书公钥异常异常:"+e.getMessage(),e) ;
- }
- }
- public static PrivateKey getMerchantPrivateKey() {
- return merchantPrivateKey;
- }
- public static PublicKey getHelipayPublicKey() {
- return helipayPublicKey;
- }
- }
|