「マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
ユーティリティに暗号化ライブラリを含む。
証明書生成から、色々な証明書操作が可能。
バイナリ形式ファイルをpem化できる。
.NET Standardでは、OpenSSLベースのプロバイダも提供され始めている
(.NET Platform Extensions ?の 2.1以上で使用できる模様)。
以下のプロバイダがOpenSsl?ベースのプロバイダとして提供されいている。
https://github.com/dotnet/corefx/tree/master/src/System.Security.Cryptography.OpenSsl/src/System/Security/Cryptography
NuGetで検索すると以下のようなLinuxディストリビューション毎のネイティブ実装がある事を確認できる。
https://www.nuget.org/packages?q=runtime.native.System.Security.Cryptography.OpenSsl
# | 名前空間 | |
プラットフォーム | ・・・ | |
1 | runtime.debian.8-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
2 | runtime.opensuse.42.1-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
3 | runtime.rhel.7-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
4 | runtime.fedora.24-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
5 | runtime.opensuse.13.2-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
6 | runtime.ubuntu.14.04-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
7 | runtime.fedora.23-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
8 | runtime.osx.10.10-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
9 | runtime.ubuntu.16.04-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
10 | runtime.ubuntu.16.10-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
11 | runtime.opensuse.42.3-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
12 | runtime.fedora.28-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
13 | runtime.ubuntu.18.04-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
14 | runtime.debian.9-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
15 | runtime.fedora.27-x64.runtime.native | .System.Security.Cryptography.OpenSsl? |
in, outを拡張子付きで明示することで制御した方がイイ。
>openssl genrsa -rand rand.dat -out private-key.pem 2048
>openssl req -new -key private-key.pem > csr.csr 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]:. State or Province Name (full name) [Some-State]:. Locality Name (eg, city) []:. Organization Name (eg, company) [Internet Widgits Pty Ltd]:. Organizational Unit Name (eg, section) []:. Common Name (e.g. server FQDN or YOUR name) []:x Email Address []:. Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:. An optional company name []:.
>openssl x509 -in csr.csr -days 365000 -req -signkey private-key.pem > crt.crt
>openssl pkcs12 -export -out pfx.pfx -inkey private-key.pem -in crt.crt Enter Export Password: Verifying - Enter Export Password:
'*.pfxから、公開鍵 or 証明書を出力
>openssl pkcs12 -in XXX.pfx -out XXX.cer -nokeys -clcerts Enter Import Password:
・・・ Enter Import Password:
・・・ Enter Import Password:
※ 署名検証は、PUBLIC KEY, CERTIFICATEの何れか1つがあれば可能。
>openssl pkcs12 -in XXX.pfx -out XXX.pem Enter Import Password: Enter PEM pass phrase: Verifying - Enter PEM pass phrase:
>openssl pkcs12 -in pfx.pfx -out XXX.pem -nodes Enter Import Password:
>openssl x509 -in XXX.cer -pubkey -out XXX.pem
Tags: :セキュリティ, :暗号化, :証明書, :.NET Core, :.NET Standard