在linux下openssl genrsa 生成的密钥为PKCS#1格式,但在macos下生成的密钥却为PKCS#8格式。经检查发现是因为在macos上新安装了MacPorts,而MacPorts新安装的openssl为新的版本,新版本生成密钥的默认格式为pkcs#8。

➜  ~ openssl genrsa -help
Usage: genrsa [options] numbits

General options:
 -help               Display this summary
 -engine val         Use engine, possibly a hardware device

Input options:
 -3                  (deprecated) Use 3 for the E value
 -F4                 Use the Fermat number F4 (0x10001) for the E value
 -f4                 Use the Fermat number F4 (0x10001) for the E value

Output options:
 -out outfile        Output the key to specified file
 -passout val        Output file pass phrase source
 -primes +int        Specify number of primes
 -verbose            Verbose output
 -quiet              Terse output
 -traditional        Use traditional format for private keys
 -*                  Encrypt the output with any supported cipher

Random state options:
 -rand val           Load the given file(s) into the random number generator
 -writerand outfile  Write random data to the specified file

Provider options:
 -provider-path val  Provider load path (must be before 'provider' argument if required)
 -provider val       Provider to load (can be specified multiple times)
 -propquery val      Property query used when fetching algorithms

Parameters:
 numbits             Size of key in bits
openssl genrsa -traditional -out account.key 2048

感谢大家的阅读, 如有疑问可以加我微信