首先cmd 使用管理员打开 找到apache的bin目录 如 E:\phpstudy\PHPTutorial\Apache\bin E:\phpstudy\PHPTutorial\Apache\bin>openssl genrsa -out rsa_private_key.pem 1024 WARNING: can't open config file: /apache24/conf/openssl.cnf Generating RSA private key, 1024 bit long modulus .........++++++ ......................................................................++++++ e is 65537 (0x10001) 上面执行命令 出错 需要设置一下配置文件的路径 set OPENSSL_CONF=E:\phpstudy\PHPTutorial\Apache\conf\openssl.cnf E:\phpstudy\PHPTutorial\Apache\bin>set OPENSSL_CONF=E:\phpstudy\PHPTutorial\Apache\conf\openssl.cnf E:\phpstudy\PHPTutorial\Apache\bin>openssl genrsa -out rsa_private_key.pem 1024 Generating RSA private key, 1024 bit long modulus .........................++++++ ...................++++++ e is 65537 (0x10001) 就这样生成了私钥 下面生成公钥 E:\phpstudy\PHPTutorial\Apache\bin>openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -----BEGIN PRIVATE KEY----- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMcOTJ/xzAEa4J0u gC2NFbHVSoQku1TXfL4NgGS1JFZ4l7hQOdc7hlDmJLOKV/ylL2jTz/Ew+6WZZYmD /tva7TAfXfA17d7aLGvd+JeI7zE5gI9eFMK+KKJsnqyt5+NsgmW+Phjfqclb0gZs IN4oX//mJjP1Q3/wIQkCElopibytAgMBAAECgYABV61Yns7bawz8wmWG6R6uVlvs TDsfNVzYA0tMYpReKO4NBi19sB8VyJeSxmoVgB+zu0n5vHTWBxTSOpura+yRlXeQ pKSQcN1fqpY7cFRAhLrmyFgtDGuoOrAccQYmPlD/z5AO+0h5lpKbHBrgkJ/5T29+ Fo5Mn0+Rolr6koJ4wQJBAPAxUXkmHijA9g4h0d4vBTZ92jYm46/zpm3dHjFTJJoO rdlqYLjqddMtrBH7aIAqPKNyfn5kb85YnXpeLEbM8HUCQQDUJ+w6V+viLcJJhtRm lfrKlhpe+c5+KQY4ej3mzxaWp8V4BA5Ai9p01ljIMvjXZCKWzE9/6fbfpR8fGGuT XRRZAkBctpy9R8JidsFDiThqK/o2I3QkbPR8SW9Xfv+ViINbWAkxIAe/uPjMEBgY RNP8jNElQh+jh/9ERh5bSpiKp7a1AkAepyoFgACP7Gae8wErVU4oCSoEQPmp1smU TW02NQOhftoULhnVD5/fs7yeKGc1z70Dpr9xzt8hjx0BBCk+4Hr5AkEAjqrQsUYE R29nWx1kWeva+q7+6dPhlD45oX3r141J0FbwERp+CEDIAy9MwE4SS1OJ/qharjgX xGwCuQkABh0zag== -----END PRIVATE KEY-----