
我不是系統管理員或網路管理員(我有軟體開發人員背景)。我在嘗試遵循本教程來實施時發現一些困難SLL 用戶端身份驗證在 Ubuntu 20.04 版本上:https://www.makethenmakeinstall.com/2014/05/ssl-client-authentication-step-by-step/
我知道這個教程已經很老了,但除了一點之外它似乎工作得很好。
基本上我執行了上一個教程中指示的所有步驟。我在這裡總結了它們,以便如果我很好地理解我所做的事情,您也可以給我反饋:
產生憑證授權單位 (CA) 憑證:首先我要建立一個 CA 憑證。如果我很好理解的話,這就像創建我自己的個人證書頒發機構(如 cacert.org),唯一的問題是在這種情況下沒有機構驗證該 CA 頒發的證書。這種理解正確嗎?
openssl req -newkey rsa:4096 -keyform PEM -keyout ca.key -x509 -days 3650 -outform PEM -out ca.cer
基本上這個指令會要求我提供一個PEM 密碼短語我將用它來與我自己的 CA 和一些詳細資訊進行互動。我輸入這些參數:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:IT
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Notariato
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:.*
Email Address []:[email protected]
筆記:在前面的答案中,我為通用名稱添加了通配符(*),以便「忽略」將使用憑證的位置。能行嗎?
所以這個命令生成一個癌症我將使用它來產生伺服器和客戶端憑證的檔案。
我產生我的 Apache 伺服器 SSL 金鑰和憑證:這還不是客戶端證書(客戶端用來對伺服器說:「我是經過認證的客戶端!!!」的證書),這是對客戶端說:「我是正確的伺服器」的伺服器證書,而不是中間的人」。這是對的嗎?
要建立此伺服器證書,首先我會產生伺服器私鑰:
openssl genrsa -out server.key 4096
然後我使用該伺服器私鑰來產生憑證產生請求。
openssl req -new -key server.key -out server.req -sha256
在這裡它還詢問我一些參數:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:IT
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Notariato
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:*
Email Address []:[email protected]
筆記:同樣在這裡,我為通用名稱添加了通配符 (*),以便「忽略」將使用憑證的位置。能行嗎?
然後我使用憑證產生請求和 CA 憑證來產生伺服器憑證:
openssl x509 -req -in server.req -CA ca.cer -CAkey ca.key -set_serial 100 -extensions server -days 1460 -outform PEM -out server.cer -sha256
然後我嘗試透過以下方式將憑證安裝到我的 Apache 中:
將 CA 憑證複製到永久位置。我們需要在 Apache 中指定我們的 CA 證書,因為它是一個自行產生的 CA,而不是包含在所有作業系統中的證書:
cp ca.cer /etc/ssl/certs/
將伺服器憑證和私鑰複製到永久位置:
cp server.cer /etc/ssl/certs/server.crt cp server.key /etc/ssl/private/server.key
啟動 Apache 中的 SSL 模組:
a2enmod ssl
在 Apache 中啟動 SSL 網站並停用 HTTP 網站:
a2ensite 預設-ssl a2dissite 預設
現在,根據最後兩個命令的輸出,我在最後一個命令上遇到了問題:
andrea@ubuntu:~/cert$ a2ensite default-ssl
Site default-ssl already enabled
andrea@ubuntu:~/cert$ a2dissite default
ERROR: Site default does not exist!
正如你所看到的,當我表演時a2dissite 預設我正在得到這個錯誤:站點預設不存在!錯誤訊息.
為什麼?這是什麼意思?怎麼了?我該如何嘗試解決此錯誤?