使用OpenSSL生成證書,構建根證書前,需要構建隨機數文件(.rand),命令如下:
openssl rand -out private/.rand 1000
報錯如下:
OpenSSL> rand -out private\.rand 1000 Can't open private\.rand for writing, No such file or directory 8356:error:02001003:system library:fopen:No such process:crypto\bio\bss_file.c:7 4:fopen('private\.rand','wb') 8356:error:2006D080:BIO routines:BIO_new_file:no such file:crypto\bio\bss_file.c :81: error in rand
竟然找不到路徑
查看了OpenSSL的cfg文件也沒錯
無奈,直接使用了絕對路徑,命令如下:
OpenSSL> rand -out C:\CA\private\.rand 1000
搞定!
原因分析:
因為把openssl放入了path,因此,在cmd命令行下輸入openssl后,回車,進入openssl的命令行,默認在%OPENSSL_HOME%\bin\目錄下了
執行openssl rand -out XXX命令時,不需要前的openssl,只需要輸入rand -out XX即可
問題來了,我的第一個命令:rand -out private\.rand 1000 ,使用的是相對路徑(openssl的工作目錄是C:\CA),肯定在%OPENSSL_HOME%\bin\目錄下找不到
因此,解決方案二:
cd C:C/CA
openssl -out private\.rand 1000
搞定!(注意命令前必須有openssl)
OpenSSL命令參考: