如何使用 RSA 私钥和自签名证书生成 p12 文件

如何使用 RSA 私钥和自签名证书生成 p12 文件

我相信两周前下面的具体程序对我有用,但现在不行了。我从 RSA 私钥开始rsa.pem并生成我自己的自签名证书:

openssl req -new -x509 -key rsa.pem -out rsa.cer

然后我尝试创建一个p12文件:

openssl pkcs12 -export -out rsa.p12 -inkey rsa.pem -in rsa.cer

但我只收到以下消息:

Usage: pkcs12 [options]
where options are
-export       output PKCS12 file
-chain        add certificate chain
-inkey file   private key if not infile
-certfile f   add all certs in f
-CApath arg   - PEM format directory of CA's
-CAfile arg   - PEM format file of CA's
-name "name"  use name as friendly name
-caname "nm"  use nm as CA friendly name (can be used more than once).
-in  infile   input filename
-out outfile  output filename
-noout        don't output anything, just verify.
-nomacver     don't verify MAC.
-nocerts      don't output certificates.
-clcerts      only output client certificates.
-cacerts      only output CA certificates.
-nokeys       don't output private keys.
-info         give info about PKCS#12 structure.
-des          encrypt private keys with DES
-des3         encrypt private keys with triple DES (default)
-seed         encrypt private keys with seed
-aes128, -aes192, -aes256
              encrypt PEM output with cbc aes
-camellia128, -camellia192, -camellia256
              encrypt PEM output with cbc camellia
-nodes        don't encrypt private keys
-noiter       don't use encryption iteration
-nomaciter    don't use MAC iteration
-maciter      use MAC iteration
-nomac        don't generate MAC
-twopass      separate MAC, encryption passwords
-descert      encrypt PKCS#12 certificates with triple DES (default RC2-40)
-certpbe alg  specify certificate PBE algorithm (default RC2-40)
-keypbe alg   specify private key PBE algorithm (default 3DES)
-macalg alg   digest algorithm used in MAC (default SHA1)
-keyex        set MS key exchange type
-keysig       set MS key signature type
-password p   set import/export password source
-passin p     input file pass phrase source
-passout p    output file pass phrase source
-engine e     use engine e, possibly a hardware device.
-rand file:file:...
              load the file (or the files in the directory) into
              the random number generator
-CSP name     Microsoft CSP name
-LMK          Add local machine keyset attribute to private key

我只是关注以前的帖子:

https://stackoverflow.com/questions/38841563/create-rsacryptoserviceprovider-object-using-rsa-private-key-file-in-c-sharp

https://stackoverflow.com/questions/10994116/openssl-convert-pem-containing-only-rsa-private-key-to-pkcs12

答案1

事实证明,这是破折号的字符编码问题,它与复制和粘贴混淆了。我刚刚重新输入命令,它就起作用了。

相关内容