从cer和pfx证书文件获取公、私钥

从cer和pfx证书文件获取公、私钥一、背景最近在对接chinapay支付接口。chinapay会为每个商户号都会提供两个证书文件(cer和pfx),对接时使用chinapay提供的工具jar包,直接读取文件路径,进行请求体的签名、验签、加密、解密。chinapay提供的jar包工具类需要两个配置文件://该文件是:对方的公钥证书,内部只有公钥信息,用于请求的加密及响应的验签verify.file=/Users/macuser/Desktop/chinaPay/368_cp_test.cer//该文件是:自己的证书,

大家好,又见面了,我是你们的朋友全栈君。

其他文章:

安全系列之——手写JAVA加密、解密

安全系列之——数据传输的完整性、私密性、源认证、不可否认性

安全系列之——主流Hash散列算法介绍和使用

安全系列之——RSA的公钥私钥有多少人能分的清楚?RSA的签名验签与加密解密如何使用公私钥?

安全系列之——RSA的前世今生

cfssl生成密钥对

从cer和pfx证书文件获取公、私钥


一、背景

最近在对接chinapay支付接口。

chinapay会为每个商户号都会提供两个证书文件(cer和pfx),对接时使用chinapay提供的工具jar包,直接读取文件路径,进行请求体的签名、验签、加密、解密。

chinapay提供的jar包工具类需要两个配置文件:

// 该文件是:对方的公钥证书,内部只有公钥信息,用于请求的加密及响应的验签
verify.file=/Users/macuser/Desktop/chinaPay/368_cp_test.cer
    
// 该文件是:自己的证书,内部有自己的公钥和私钥信息,私钥用于请求的签名和响应的解密
sign.file=/Users/macuser/Desktop/chinaPay/0000XXXXXXX368.pfx
sign.file.password=1XXXXXX1 #解pfx文件需要的秘密
sign.cert.type=PKCS12       #pfx文件的格式 参考信息https://www.chinassl.net/ssltools/convert-ssl.html

这种方式会导致文件难以管理。因此可以将相关的文件解出来,并通过硬编码的形式对请求和响应进行签名/验签/加密/解密相关的操作。

关键是从上面两个文件中获得商户的公钥(用于加密和验签)、自己的私钥(用于解密和签名),即可解决上面的问题。

二、cer和pfx文件内容

368_cp_test.cer

该文件是验签时的对方的公钥证书,不能直接使用,需要通过该公钥证书获得公钥。

wuxiaolong:0000xxxxxxxx368 macuser$ cat /Users/macuser/Desktop/chinaPay/368_cp_test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AsGA1UdDwQEAwID6DAdBgNV
HQ4EFgQUGPMS6ST14xhGMMgT5+tjkrd8/zgwHQYDVR0lBBYwFAYIKwYBBQUHAwIG
CCsGAQUFBwMEMA0GCSqGSIb3DQEBBQUAA4IBAQBniQ/NMQlR0t2C2GXdDCmRFZMT
vQiU/5RvUhhE9hjFgPqUidBvHDpPXZ2q5FOifQUAFRsxt5xTnuiQaYQ7idTtgw1D
UulvxwbuM6Pjo8dE5xTTU2K8mlzuNxKfaBFxvPWvclLGugTJ8o6OrVY7LGkg12P1
cMunaJ08GJeIEm6GViRACCH+gISqjFZaqLQq+Qkd2hEjIaYbk5y4TT71Tv3FgKvn
Jzdc3uZYpHVpyUT+dh7pJXBF62/z3LVWTMl4d9CY7vfBFCI2bYqQt5pAkK3d80r8
pDI0+TqII+9waJBacw6DTsAk7LWr1r4h0x+ljL+kC38vOktbMxVjsEpND4OP
-----END CERTIFICATE-----
wuxiaolong:0000xxxxxxxxx368 macuser$

0000xxxxxxxxx368.pfx

该文件是请求方(自己)的数字证书,可以使用相关的本地/在线工具将pfx把文件解出来。
在线解析地址:https://geshi.sslzhengshu.com/
将文件从pkcs12转成pem格式,需要输入上面配置文件中的sign.file.password
在线解析后,会获得一个zip文件,解压后获得三个文件:

  1. 0000xxxxxxxxxxx368.cer 该文件应该是请求方的公钥
  2. 0000xxxxxxxxxxx368.key 该文件是请求方的私钥,签名会使用,但是不能直接使用
  3. ca.crt 该文件应该是ca的根证书
    三个文件的内容如下:
wuxiaolong:0000xxxxxxxx368 macuser$ ls
0000xxxxxxxx368.cer 0000xxxxxxxx368.key ca.crt
wuxiaolong:0000xxxxxxxx368 macuser$
wuxiaolong:0000xxxxxxxx368 macuser$
wuxiaolong:0000xxxxxxxx368 macuser$
wuxiaolong:0000xxxxxxxx368 macuser$ cat ca.crt
-----BEGIN CERTIFICATE-----
MIIDzjCCAragAwIBAgIKGNDz/H99Hd/CxjANBgkqhkiG9w0BAQUFADBZMQswCQYD
VQQGEwJDTjE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7cBmfZbBaXZqcK2EOaDeUg3tVshcCgYBdMsZJvEjgdyuey1sUFonx
N1iP7VeV0o2sAyyo9tqngFkT2OsRyuS4p8SS6kwR8xlV+BvXkcueIvQ/fs0CgH63
YtUdW+QezvV4hwlCoZa97UN/5zImyc6vywBrWJ6dWFg1vMO7fQPvzugJn+QO7+hE
fQ7nUw0Y4dkyMk7W+Rg8RQKBgQDhyvjJc8zq8N2bCI93Gf+512PKAQsDX8DbRY/O
+KhiIz6t3r2hd3uyP1kC9WADetMdKJdcjf+/yKQ5VWimT69JS+pSfa34+3RTq6sp
gLWF4aUpqYMcYxFjc0Qahb30CjE6/zkMPndZGlFpvnoDFvWI73XAHT4stYMHA217
aa8m1wKBgBPpT7mRqDcYVnhIVCzH0RKaphmzyux7GsUIEqlX3lmrKrIG7okuzSbu
4hSDX5fRmPRSVLPUK4vOuLYREm/YMbE/2N6pRfudMf53zJDeUQnUhc89a6nDEQB4
wpArMpm+WCq+iiJ46lTSNZC7Yu0fBUrPF9eQYiK988Hf8It7RsPm
-----END RSA PRIVATE KEY-----
wuxiaolong:0000xxxxxxxx368 macuser$

其中0000xxxxxxxxxxx368.key文件是请求chinapay接口签名时使用的私钥,当前是pkcs1格式。
net,ios中rsa加解密使用的是pkcs1,而java使用的是pkcs8。因为当前这个文件是pkcs1,java不能直接使用,所以需要转换。

pkcs1格式: —–BEGIN RSA PRIVATE KEY—– XXXXXXXXXXXXXXXXX —–END RSA PRIVATE KEY—–
pkcs8格式: —–BEGIN PRIVATE KEY—– XXXXXXXXXXXXXXXXX —–END PRIVATE KEY—–

可以使用openssl将pkcs1转换成pkcs8

三、公钥证书转公钥

将368_cp_test.cer公钥证书转换成公钥

public static PublicKey getPublicKey() throws SecurityException { 

String verifyFile = "/Users/macuser/Desktop/chinaPay/368_cp_test.cer";
if (SecssUtil.isEmpty(verifyFile)) { 

throw new SecurityException(SecssConstants.VERIFY_CERT_ERROR);
} else { 

CertificateFactory cf = null;
FileInputStream in = null;
try { 

cf = CertificateFactory.getInstance("X.509");
in = new FileInputStream(verifyFile);
X509Certificate verifyCert = (X509Certificate) cf.generateCertificate(in);
PublicKey pubKey = verifyCert.getPublicKey();
String pk = com.sun.org.apache.xerces.internal.impl.dv.util.Base64.encode(pubKey.getEncoded());
System.out.println("从证书中获得公钥是:" +pk);
if (in != null) { 

try { 

in.close();
} catch (IOException var16) { 

}
}
return pubKey;
} catch (Exception var17) { 

LogUtil.writeErrorLog("初始化验签证书异常", var17);
if (in != null) { 

try { 

in.close();
} catch (IOException var15) { 

}
}
throw new SecurityException(SecssConstants.INIT_VERIFY_CERT_ERROR);
} finally { 

if (in != null) { 

try { 

in.close();
} catch (IOException var14) { 

}
}
}
}
}

四、安装openssl并转换私钥(将pkcs1转换成pkcs8)

[root@iZuf61pdvb2o7cf4mu9ccyZ ~]# wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
--2021-04-06 17:24:19--  https://www.openssl.org/source/openssl-1.1.1k.tar.gz
正在解析主机 www.openssl.org... 104.102.153.249, 2600:1417:76:592::c1e, 2600:1417:76:591::c1e
正在连接 www.openssl.org|104.102.153.249|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9823400 (9.4M) [application/x-gzip]
正在保存至: “openssl-1.1.1k.tar.gz”
100%[==================================================================================================================================================================>] 9,823,400   12.1M/s   in 0.8s   
2021-04-06 17:24:21 (12.1 MB/s) - 已保存 “openssl-1.1.1k.tar.gz” [9823400/9823400])
[root@iZuf61pdvb2o7cf4mu9ccyZ ~]# ls
[root@iZuf61pdvb2o7cf4mu9ccyZ ~]# tar -zxvf openssl-1.1.1k.tar.gz 
openssl-1.1.1k/
openssl-1.1.1k/ACKNOWLEDGEMENTS
openssl-1.1.1k/AUTHORS
openssl-1.1.1k/CHANGES
openssl-1.1.1k/CONTRIBUTING
openssl-1.1.1k/Configurations/
openssl-1.1.1k/Configurations/00-base-templates.conf
openssl-1.1.1k/Configurations/10-main.conf
openssl-1.1.1k/Configurations/15-android.conf
[root@iZuf61pdvb2o7cf4mu9ccyZ ~]#
[root@iZuf61pdvb2o7cf4mu9ccyZ ~]# cd openssl-1.1.1k
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]# ll
总用量 1032
-rw-rw-r--  1 root root     87 325 21:28 ACKNOWLEDGEMENTS
drwxrwxr-x  3 root root   4096 325 21:28 apps
-rw-rw-r--  1 root root   2549 325 21:28 appveyor.yml
-rw-rw-r--  1 root root    854 325 21:28 AUTHORS
-rw-rw-r--  1 root root   4099 325 21:28 build.info
-rw-rw-r--  1 root root 595440 325 21:28 CHANGES
-rwxrwxr-x  1 root root  28586 325 21:28 config
-rw-rw-r--  1 root root   2510 325 21:28 config.com
drwxrwxr-x  2 root root   4096 325 21:28 Configurations
-rwxrwxr-x  1 root root 130245 325 21:28 Configure
-rw-rw-r--  1 root root   3627 325 21:28 CONTRIBUTING
drwxrwxr-x 64 root root   4096 325 21:28 crypto
drwxrwxr-x  9 root root   4096 325 21:28 demos
drwxrwxr-x  7 root root   4096 325 21:28 doc
drwxrwxr-x  3 root root   4096 325 21:28 engines
-rw-rw-r--  1 root root  11055 325 21:28 e_os.h
drwxrwxr-x  3 root root   4096 325 21:28 external
-rw-rw-r--  1 root root     84 325 21:28 FAQ
drwxrwxr-x  2 root root   4096 325 21:28 fuzz
drwxrwxr-x  5 root root   4096 325 21:28 include
-rw-rw-r--  1 root root  57824 325 21:28 INSTALL
-rw-rw-r--  1 root root   6121 325 21:28 LICENSE
drwxrwxr-x  2 root root   4096 325 21:28 ms
-rw-rw-r--  1 root root  44165 325 21:28 NEWS
-rw-rw-r--  1 root root   4492 325 21:28 NOTES.ANDROID
-rw-rw-r--  1 root root   2093 325 21:28 NOTES.DJGPP
-rw-rw-r--  1 root root   4578 325 21:28 NOTES.PERL
-rw-rw-r--  1 root root   5532 325 21:28 NOTES.UNIX
-rw-rw-r--  1 root root   3861 325 21:28 NOTES.VMS
-rw-rw-r--  1 root root   7488 325 21:28 NOTES.WIN
drwxrwxr-x  2 root root   4096 325 21:28 os-dep
-rw-rw-r--  1 root root   3158 325 21:28 README
-rw-rw-r--  1 root root  16069 325 21:28 README.ENGINE
-rw-rw-r--  1 root root     61 325 21:28 README.FIPS
drwxrwxr-x  4 root root   4096 325 21:28 ssl
drwxrwxr-x 11 root root  12288 325 21:28 test
drwxrwxr-x  2 root root   4096 325 21:28 tools
drwxrwxr-x  3 root root   4096 325 21:28 util
drwxrwxr-x  2 root root   4096 325 21:28 VMS
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]# ./config
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]# make
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _all
make[1]: Entering directory `/root/openssl-1.1.1k' make[1]: Leaving directory `/root/openssl-1.1.1k' make[1]: Entering directory `/root/openssl-1.1.1k' gcc -I. -Iinclude -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib64/engines-1.1\"" -DNDEBUG -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c gcc -I. -Iinclude -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib64/engines-1.1\"" -DNDEBUG -MMD -MF apps/apps.d.tmp -MT apps/apps.o -c -o apps/apps.o apps/apps.c gcc -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG -MMD -MF test/x509_time_test.d.tmp -MT test/x509_time_test.o -c -o test/x509_time_test.o test/x509_time_test.c rm -f test/x509_time_test ${ 
LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \ -o test/x509_time_test test/x509_time_test.o \ test/libtestutil.a -lcrypto -ldl -pthread gcc -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG -MMD -MF test/x509aux.d.tmp -MT test/x509aux.o -c -o test/x509aux.o test/x509aux.c rm -f test/x509aux ${ 
LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \ -o test/x509aux test/x509aux.o \ test/libtestutil.a -lcrypto -ldl -pthread /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ "-oMakefile" apps/CA.pl.in > "apps/CA.pl" chmod a+x apps/CA.pl /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ "-oMakefile" apps/tsget.in > "apps/tsget.pl" chmod a+x apps/tsget.pl /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ "-oMakefile" tools/c_rehash.in > "tools/c_rehash" chmod a+x tools/c_rehash /usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ "-oMakefile" util/shlib_wrap.sh.in > "util/shlib_wrap.sh" chmod a+x util/shlib_wrap.sh make[1]: Leaving directory `/root/openssl-1.1.1k'
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]# make install
make depend && make _build_libs
make[1]: Entering directory `/root/openssl-1.1.1k' make[1]: Leaving directory `/root/openssl-1.1.1k' make[1]: Entering directory `/root/openssl-1.1.1k' make[1]: Nothing to be done for `_build_libs'.
make[1]: Leaving directory `/root/openssl-1.1.1k' *** Installing runtime libraries install libcrypto.so.1.1 -> /usr/local/lib64/libcrypto.so.1.1 install libssl.so.1.1 -> /usr/local/lib64/libssl.so.1.1 *** Installing development files created directory `/usr/local/include/openssl'
install ./include/openssl/aes.h -> /usr/local/include/openssl/aes.h
install ./include/openssl/asn1.h -> /usr/local/include/openssl/asn1.h
install ./include/openssl/asn1_mac.h -> /usr/local/include/openssl/asn1_mac.h
install ./include/openssl/asn1err.h -> /usr/local/include/openssl/asn1err.h
install ./include/openssl/asn1t.h -> /usr/local/include/openssl/asn1t.h
install ./include/openssl/async.h -> /usr/local/include/openssl/async.h
install ./include/openssl/asyncerr.h -> /usr/local/include/openssl/asyncerr.h
install ./include/openssl/bio.h -> /usr/local/include/openssl/bio.h
install ./include/openssl/bioerr.h -> /usr/local/include/openssl/bioerr.h
install ./include/openssl/blowfish.h -> /usr/local/include/openssl/blowfish.h
install ./include/openssl/bn.h -> /usr/local/include/openssl/bn.h
/usr/local/share/doc/openssl/html/man3/i2d_re_X509_REQ_tbs.html -> /usr/local/share/doc/openssl/html/man3/i2d_re_X509_tbs.html
/usr/local/share/doc/openssl/html/man3/o2i_SCT_LIST.html
/usr/local/share/doc/openssl/html/man3/i2o_SCT_LIST.html -> /usr/local/share/doc/openssl/html/man3/o2i_SCT_LIST.html
/usr/local/share/doc/openssl/html/man3/o2i_SCT.html -> /usr/local/share/doc/openssl/html/man3/o2i_SCT_LIST.html
/usr/local/share/doc/openssl/html/man3/i2o_SCT.html -> /usr/local/share/doc/openssl/html/man3/o2i_SCT_LIST.html
/usr/local/share/doc/openssl/html/man5/config.html
/usr/local/share/doc/openssl/html/man5/x509v3_config.html
/usr/local/share/doc/openssl/html/man7/Ed25519.html
/usr/local/share/doc/openssl/html/man7/Ed448.html -> /usr/local/share/doc/openssl/html/man7/Ed25519.html
/usr/local/share/doc/openssl/html/man7/RAND.html
/usr/local/share/doc/openssl/html/man7/RAND_DRBG.html
/usr/local/share/doc/openssl/html/man7/RSA-PSS.html
/usr/local/share/doc/openssl/html/man7/SM2.html
/usr/local/share/doc/openssl/html/man7/X25519.html
/usr/local/share/doc/openssl/html/man7/X448.html -> /usr/local/share/doc/openssl/html/man7/X25519.html
/usr/local/share/doc/openssl/html/man7/bio.html
/usr/local/share/doc/openssl/html/man7/crypto.html
/usr/local/share/doc/openssl/html/man7/ct.html
/usr/local/share/doc/openssl/html/man7/des_modes.html
/usr/local/share/doc/openssl/html/man7/evp.html
/usr/local/share/doc/openssl/html/man7/ossl_store-file.html
/usr/local/share/doc/openssl/html/man7/ossl_store.html
/usr/local/share/doc/openssl/html/man7/passphrase-encoding.html
/usr/local/share/doc/openssl/html/man7/proxy-certificates.html
/usr/local/share/doc/openssl/html/man7/scrypt.html
/usr/local/share/doc/openssl/html/man7/ssl.html
/usr/local/share/doc/openssl/html/man7/x509.html
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]# ls
ACKNOWLEDGEMENTS  build.info  configdata.pm   crypto   e_os.h    include        libcrypto.pc      libssl.map     LICENSE   NOTES.ANDROID  NOTES.VMS   pod2htmd.tmp   README.FIPS  util
apps              CHANGES     Configurations  demos    external  INSTALL        libcrypto.so      libssl.pc      Makefile  NOTES.DJGPP    NOTES.WIN   pod2htmi.tmp   ssl          VMS
appveyor.yml      config      Configure       doc      FAQ       libcrypto.a    libcrypto.so.1.1  libssl.so      ms        NOTES.PERL     openssl.pc  README         test
AUTHORS           config.com  CONTRIBUTING    engines  fuzz      libcrypto.map  libssl.a          libssl.so.1.1  NEWS      NOTES.UNIX     os-dep      README.ENGINE  tools
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
[root@iZuf61pdvb2o7cf4mu9ccyZ openssl-1.1.1k]#
// 将0000xxxxxxxxxx368.key文件内容放入rsa_private_key.pem
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# vim rsa_private_key.pem
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# cat rsa_private_key.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA05VF6CyW0Xc/Opg32ddFQaeRRgJF6puEKQVPq3s0C+BvBt4l
1/sx7yrkKqntcBsiUFBwayVqr3geL1V/SlooL6Trt6iTX5JKyk/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QezvV4hwlCoZa97UN/5zImyc6vywBrWJ6dWFg1vMO7fQPvzugJn+QO7+hE
fQ7nUw0Y4dkyMk7W+Rg8RQKBgQDhyvjJc8zq8N2bCI93Gf+512PKAQsDX8DbRY/O
+KhiIz6t3r2hd3uyP1kC9WADetMdKJdcjf+/yKQ5VWimT69JS+pSfa34+3RTq6sp
gLWF4aUpqYMcYxFjc0Qahb30CjE6/zkMPndZGlFpvnoDFvWI73XAHT4stYMHA217
aa8m1wKBgBPpT7mRqDcYVnhIVCzH0RKaphmzyux7GsUIEqlX3lmrKrIG7okuzSbu
4hSDX5fRmPRSVLPUK4vOuLYREm/YMbE/2N6pRfudMf53zJDeUQnUhc89a6nDEQB4
wpArMpm+WCq+iiJ46lTSNZC7Yu0fBUrPF9eQYiK988Hf8It7RsPm
-----END RSA PRIVATE KEY-----
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
#转换
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory #缺少库
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
#添加库
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# find / -name libssl.so.1.1
/root/openssl-1.1.1k/libssl.so.1.1
/usr/local/lib64/libssl.so.1.1
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# ln -s /root/openssl-1.1.1k/libssl.so.1.1 /usr/lib64/libssl.so.1.1 #第一步
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt
openssl: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1 #第二步
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
#转换成功
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDTlUXoLJbRdz86
mDfZ10VBp5FGAkXqm4QpBU+rezQL4G8G3iXX+zHvKuQqqe1wGyJQUHBrJWqveB4v
VX9KWigvpOu3qJNfkkrKT/unhAPF6+mrVIGFMsiCYm2MjZNsVxIld8WkI2soRUl3
H9/fzKzO8ZodTbD2UvHACwE7MiQdrT+e/M0TbeNk2OFUnr6mjuDlX1tgLmf6PTSv
is2tChEKiWYu0v9YakkfXfvoF3FoFkiu1rrNaMIijzF1aw3HDytJ1carmm3HK3Ou
3P5WbE7z/zf/+zYFwm0FXEkLz9NU5qWqGJJ6qfc1icb0M85XMbavaHoYiva1MEdD
1cc/Z8aNAgMBAAECggEAabmxkO6W/lxD8BeX8Pas2L3Ozdjc7vp+87B/uwR5YWXo
lNn0txQCQ6x/DwKSbu5gGxnW0vODd+Lh0m06igC7C/OxBbjqy1rinG2TJoXFDOVx
gfdcMR7LKrvcWdt0yzJHEwnibL52EU1uBGSdDcvMniwEApiL0MppmrjlCJtpiJnc
u6yjxbieNF7DjutyHRdRkrTXL6+K74hr0QOMdlRroBDyaPUKF67Bf5O7chd7BnZB
pAV6mAz7R0EbSmbmsXYV7tZKIfZkM0GIZTv8OOAOdTmJCAU2c71xFDVh+QU2jI+y
d4AdrESRI/TWmUUVXWxTOBy7YjmOQQDlJgxWUSdyUQKBgQDcVAeTuJXwYCaeWDBP
W65KXlHPs9Q4dhYvxNTNVbYlOXZxrVv7jHGUqYVHe8CBbHZcGabdfxQJz/coTynF
SD5spkNp92g1g9ECiPJBhIdDW1fB5RdOzqVQJygLUAtumgvpzyT1f3yeV9/eYrbe
vKLKSSHIkugxVvQDlBOD4xtm+wKBgQD11shTcjLRXXYxvl66xZjl/2uGkoCwSh89
AJqxHzFigqWOdbZHlR5v/nuX1DlRHurgFq3bwwfNpXQ2dlFo0yRc6nT+LOwI+KtO
evdD3UZEHux0X4Ii/ox8od3j4OvTwKclvRnImTmP9Tmh6jtwGZ9lsFpdmpwrYQ5o
N5SDe1WyFwKBgF0yxkm8SOB3K57LWxQWifE3WI/tV5XSjawDLKj22qeAWRPY6xHK
5LinxJLqTBHzGVX4G9eRy54i9D9+zQKAfrdi1R1b5B7O9XiHCUKhlr3tQ3/nMibJ
zq/LAGtYnp1YWDW8w7t9A+/O6Amf5A7v6ER9DudTDRjh2TIyTtb5GDxFAoGBAOHK
+MlzzOrw3ZsIj3cZ/7nXY8oBCwNfwNtFj874qGIjPq3evaF3e7I/WQL1YAN60x0o
l1yN/7/IpDlVaKZPr0lL6lJ9rfj7dFOrqymAtYXhpSmpgxxjEWNzRBqFvfQKMTr/
OQw+d1kaUWm+egMW9YjvdcAdPiy1gwcDbXtprybXAoGAE+lPuZGoNxhWeEhULMfR
EpqmGbPK7HsaxQgSqVfeWasqsgbuiS7NJu7iFINfl9GY9FJUs9Qri864thESb9gx
sT/Y3qlF+50x/nfMkN5RCdSFzz1rqcMRAHjCkCsymb5YKr6KInjqVNI1kLti7R8F
Ss8X15BiIr3zwd/wi3tGw+Y=
-----END PRIVATE KEY-----
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]#
[root@iZuf61pdvb2o7cf4mu9ccyZ mytest]# 

通过上面的操作,就完成了两个操作:

1.cer公钥证书转公钥

2.pfx证书转私钥的操作

后面在代码中就可以通过公钥做验签和加密,通过私钥做签名和解密了

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/132828.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(1)


相关推荐

  • mysql读写分离的意义_MySQL读写分离

    mysql读写分离的意义_MySQL读写分离如何实现mysql的读写分离?就是基于主从复制架构,简单来说,就搞一个主库,挂多个从库,然后我们就单单只是写主库,然后主库会自动把数据给同步到从库上去。MySQL主从复制原理的是啥?主库将变更写binlog日志,然后从库连接到主库之后,从库有一个IO线程,将主库的binlog日志拷贝到自己本地,写入一个中继日志中。接着从库中有一个SQL线程会从中继日志读取binlog,然后执行binlog日志中的…

  • 堆叠降噪自动编码器 Stacked Denoising Auto Encoder(SDAE)

    堆叠降噪自动编码器 Stacked Denoising Auto Encoder(SDAE)自动编码器(Auto-Encoder,AE)自编码器(autoencoder)是神经网络的一种,经过训练后能尝试将输入复制到输出。自编码器内部有一个隐藏层h,可以产生编码(code)表示输入。该网络可以看作由两部分组成:一个由函数h=f(x)表示的编码器和一个生成重构的解码器r=g(h)。我们不应该将自编码器设计成输入到输出完全相等。这通常需要向自编码器强加一些约束,使它只能近…

  • 校花网爬取校花照片

    校花网爬取校花照片"""今天我们开始尝试,第一次学习爬虫的第一个案例,去校花网上爬取一些校花的照片"""fromrequests_htmlimportH

  • Win知识 – 程序是怎样跑起来的(合集)

    Win知识 – 程序是怎样跑起来的(合集)操作系统的硬件控制功能,通常是通过一些小的函数集合体的形式来提供的。这些函数及调用函数的行为统称为系统调用(systemcall),也就是应用对操作系统(system)的功能进行调用(call)的意思。在前面的程序中用到了time()及printf()等函数,这些函数内部也都使用了系统调用。这里之所以用“内部”这个词,是因为在Windows操作系统中,提供返回当前日期和时刻,以及在显示器中显示字…

  • redis连接时报错:Could not connect to Redis at 192.168.1.21:6379: Connection refused

    redis连接时报错:Could not connect to Redis at 192.168.1.21:6379: Connection refusedbrewinstallredis安装好redis用terminal连接redis查看状态时时出现错误:[root@admin2bin]#redis-cli-h192.168.1.21infoReplicationCouldnotconnecttoRedisat192.168.1.21:6379:Connectionrefused但是查看127.0.0…

  • Python常用数组操作函数

    Python常用数组操作函数Python常用数组操作函数1.添加数组元素:列表:list=[‘sadsad’,1,‘哈哈’,‘是否’]append():向末尾添加一个内容如:list.append(‘我是最后一个’)输出:[‘sadsad’,1,‘哈哈’,‘是否’,‘我是最后一个’]extend():向末尾添加多个内容如:list.extend([‘大毛’,‘二毛’])输出:[‘sadsad’,1,…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号