## 憑證 API ### 1. 前置作業(上期計畫成果) #### (1.1) 架設 Client 端 1. 在[此連結](<https://t72m1-my.sharepoint.com/personal/m11109105_aclab_cs_ntust_edu_tw/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fm11109105%5Faclab%5Fcs%5Fntust%5Fedu%5Ftw%2FDocuments%2F%E8%BB%8A%E8%81%AF%E7%B6%B2%2F%E5%AF%A6%E4%BD%9C%2F%E6%9C%80%E7%B5%82%E6%9D%BF&ga=1>)下載 "Vanetza_ieee.ova" (其他檔案不用下載)。 2. 執行該虛擬機。 #### (1.2) 連上 Server (用自己的電腦連,而不是用client端連上server) windows power shell 輸入 : ``` ssh -p 8888 vanetza@140.118.155.146 ``` 密碼 : vanetza_ieee #### (1.3) 命令測試 Server 作為 RA,client 作為 ACA。將進行以下動作,1、2、5步在server端執行,3、4、6步在client端執行。且都必須在/build路徑下執行。 :::warning note1 : 第5步指令會堵塞當前終端機,需要在指令後加&讓他換到背景執行,或是另外開終端機執行。 note2 : 第7步Server端在處理完一個請求後會關閉P2P伺服器,所以第6步結束後,你需要回到第5步再開一次。 note3 : 過程中你可以觀察 "../test/ACA/"、"../test/RCA/、"../test/Cache/"資料夾有什麼檔案生成。 ::: 1. Server 生成私鑰 ``` bin/certify generate-key ../test/RCA/root.key ``` 2. Server 生成自己的憑證 ``` bin/certify generate-root --subject-key ../test/RCA/root.key ../test/RCA/root.cert ``` 3. Client 生成自己的私鑰 ``` bin/certify generate-key ../test/ACA/aa.key ``` 4. Client 生成自己的公鑰 ``` bin/certify extract-public-key --private-key ../test/ACA/aa.key ../test/ACA/aa.pub ``` 5. Server 端開啟 P2P 伺服器,用於給 Client 提出憑證發放或憑證驗證需求 ``` bin/certify server --port 23232 ``` >我這邊之後會再開更多 port 讓你測試,我怕我們兩個共用 port 會打架。 6. Client 向 Server 端提出憑證發放請求 ``` bin/certify client --action request --file_path ../test/ACA/aa.pub --address 140.118.155.146 --port 23232 ``` 7. Client 向 Server 端提出憑證驗證請求 ``` bin/certify client --action verify --file_path ../test/Cache/aa.cert --address 140.118.155.146 --port 23232 ``` ### 2. 上期計畫修正 #### (2.1) server.cpp 與 client.cpp 的錯誤報告 在 "tools/certify/commands" 路徑下有兩個檔案,為 "server.cpp" 與 "client.cpp",其為負責憑證發放與驗證的伺服器程式碼。然而程式碼中有優化空間,[此連接](<https://github.com/moulxi/vanetza_collection>)中有修正後的檔案,複製過去覆蓋即可。詳細優化如下 : - 修正 TCP socket 傳輸問題 -