• yam天空
  • 天空部落
  • 新聞
  • 登入 註冊 網誌隨便逛
  • 加入天空部落
  • 華文部落格大賞結果出爐!

網誌 相簿 影音 PK吧! Honda嬉遊趣
即時新聞 影音新聞 新聞專輯 政治新聞 財經新聞 娛樂新聞 運動新聞 兩岸新聞 科技新聞
管理介面 發表網誌 發表日記 上傳相片 上傳影音 管理留言
推薦這個部落格: 62

Prince's Blog

想到什麼就寫些什麼,重要的是,為自己留下一點回憶...

網誌 |相簿 |好友 |留言板
[練習]P賽道 | 主頁 | [音樂]丁噹 - 花火
November 4, 2009
[小筆記]從pfx檔extract出 Private Key以文找文
wangprince 在天空部落發表於12:08:17 | 電腦與網際網路
鼓勵此網誌:0 

之前在寫一些加解密程式,其中用到數位信封的東西,
 

數位信封
  • 優點:結合對稱式加密與公開金鑰加密
  • 封信(Sealing):
    • 發文者先將欲傳送的訊息用「私密金鑰碼系統」(Private-Key Cryptosystem,如 AES)予以加密。
    • 訊息加密時所到的「加密金鑰」(Encryption Key)則根據收文者於「公開金鑰密碼系統」( Public-Key Cryptosystem,如 RSA)上對外公開的加密金鑰予以加密後與加密的訊息傳送出去。
  • 開信(Opening):
    • 收文者先以「公開金鑰密碼系統」上的私密金鑰,解出訊息內的對稱式「解密金鑰」,再用此對稱式「解密金鑰」將訊息恢復成明文。
       

為了要能在程式內使用pfx檔的 publick key 和 private key,所以就要先將它們extract出來....
還好openssl幫上一點忙了

這裡定義了PFX跟PEM檔案的意義

  • PFX : PFX defines a file format commonly used to store private with accompanying public key certificates, protected with a password-based symmetric key (standard-PKCS12).
  • PEM : Openssl usages PEM (Privacy Enhanced Mail Certificate) to store the private key.
    If you have the openssl then go to command prompt and run the following commands (If not, download it from openssl, you can either download binary or source and then compile).

If you want to extract private key from a pfx file and write it to PEM file

openssl.exe pkcs12 -in publicAndprivate.pfx -nocerts -out privateKey.pem
If you want to extract the certificate file (the signed public key) from the pfx file
openssl.exe pkcs12 -in publicAndprivate.pfx -clcerts -nokeys -out publicCert.pem
To remove the password from the private key file.
openssl.exe rsa -in privateKey.pem -out private.pem

 


This is required as, at the time of exporting privateKey, you have added a password to the private key to secure it. If you left the password with it, it will keep asking the password as any application tries to access it.

 

延伸閱讀:
  • The Most Common OpenSSL Commands

留言 (0) | 引用 (0) | 人氣 () | 轉寄
| 主頁 | 此分類下一篇:[小筆記]在UNIX中用sar命令進行系統維護
引用 (你可以針對此文寫一篇屬於自己的blog/想法,並給作者一個通告)
引用
留言 (0筆)
發表你的留言 (字數限制 最多 2000 個中文字)
私密留言: 是 否
Name:





是 否
內容:
系統公告
個人檔案
個人圖檔
ID:wangprince
暱稱:Prince
地區:臺北市
  • 訂閱 |
    • 我要訂閱此部落格的
    • 日記
    • 網誌
    • 相簿
  • 好友 |
    • 好友功能
    • 觀看好友列表
    • 觀看人緣列表
  • 人氣 |
  • 簡介 

Twitter
    wangprince的最新的回應
    • kaiti:
      六樓的,我們似乎把這裡...
    • kaiti:
      六樓的,我們似乎把這裡...
    • 219:
      4樓的 沒關係 ...
    • 219:
      哇勒... ...
    • KellyH2259:
      二十年的老友~~~這句...
    交換貼紙


    連結書籤
    • ★Xuite Prince's Blog
    • ★繼續‧思念
    好時光貼曆
    文章分類
    • 旅行 (0)
      • 沒有項目
    • 留言 (2)
    • 生活記事 (41)
    • 旅行 (14)
    • 動力交通工具 (1)
    • 音樂 (14)
    • 電腦與網際網路 (3)
    • 飲食 (5)
    我推薦誰
    誰推薦我
    人氣指數
    當日人次:
    累積人次:
    誰來我家
    SnapShot
    RSS 訂閱
    RSS2
    ATOM
    贊助商
    CC授權
    其它資訊
    本部落所刊登之內容,皆由作者個人所提供,不代表 yam 天空 本身立場。
    POWERED BY
    POWERED BY 天空部落
    會員登入│免費註冊