2013年8月19日 星期一

RB751 SSTP流程

連線設定部分都大同小異,最難處理就是憑證,
打混摸魚的狀態下花一星期才用好。
因為沒在做大事業所以沒有域名,
用domain name網上申請憑證就不可能了,
只能用OPEN SSL製作自我簽署憑證(self signed certificate)。

依照MikroTic Wiki給的Manual:Create Certificates一步一步做下去,
東西可以照著出來,
但是點下去會發現"無法保證這個憑證的完整性。憑證可能已損毀,或可能已被竄改。",
實際連線則會出現"憑證的簽章無法驗證"。
想到會不會是WIN32版的問題
特地下了ubuntu結果WIN7的Virtual PC不給跑,
只好再下VMware Player灌進去,
接著搞懂tar.gz怎麼安裝,這又是另一個故事了。

一切就緒後照著步驟再來一次結果還是一樣,
這時就不是軟體的問題而是步驟的問題了,
開始找要怎麼生成憑證,但是看了很多篇步驟做出來結果還是一樣。
最後終於找到一篇照著做沒有問題了。

1.製作根憑證
建立私鑰
>openssl genrsa -des3 -out ca.key 4096
Loading 'screen' into random state - done
Generating RSA private key, 4096 bit long modulus
.........................................................+++
.............................................................+++
e is 65537 (0x10001)
Enter pass phrase for ca.key:
Verifying - Enter pass phrase for ca.key:

建立申請檔
>openssl req -new -key ca.key -out ca.req
Enter pass phrase for ca.key:輸入根憑證密碼
Loading 'screen' into random state - done
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]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taipei
Organization Name (eg, company) [Internet Widgits Pty Ltd]:隨意
Organizational Unit Name (eg, section) []:可以不輸入
Common Name (e.g. server FQDN or YOUR name) []:不是當 Server 憑證不需要輸入
Email Address []:隨意

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:可以不輸入
An optional company name []:可以不輸入

產生憑證
>openssl x509 -req -days 7300 -sha1 -extensions v3_ca -signkey ca.key -in ca.req -out ca.crt
Loading 'screen' into random state - done
Signature ok
subject=/C=TW/ST=Taiwan/L=Taipei/O=*****/OU=*****/CN=*****/emailAdd ress=*****
Getting Private key
Enter pass phrase for ca.key:

2.製作伺服器憑證
openssl genrsa -out server.key 4096
openssl req -new -key server.key -out server.req
openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA ca.crt -CAkey ca.key -CAserial ca.srl -CAcreateserial -in server.req -out server.crt

3.製作用戶憑證
openssl genrsa -out client.key 4096
openssl req -new -key client.key -out client.req
openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA ca.crt -CAkey ca.key -CAserial ca.srl -CAcreateserial -in client.req -out client.crt

都用好後ca.crt匯入受信任的跟憑證授權單位,不然其他憑證會無法動作。
執行>mmc
檔案>新增/移除崁入式管理單元>憑證>電腦帳戶
所以無法給別人用的難點就在這,根憑證也要一起給才行。
之後client照一般程序匯入就行。
最後注意連線的名稱要跟server的CN相同
用IP有人說可以有人說不行,
這邊省事直接用一個免費的DDNS。

ref.
Manual:Interface/SSTP 官方wiki,建立SSTP
Manual:Create Certificates 官方wiki,製作CA
OPEN SSL官網
Shining Light Productions - Win32 OpenSSL 別人編譯好的OPEN SSL BIN
OpenSSL 簽發憑證方式 蔡宗融個人網站,照他的步驟終於簽好憑證
有沒有網友會建立Routeros的SSTP VPN? 01討論串,憑證匯入方法

沒有留言:

張貼留言