「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。

-戻る
--[[証明書]]
--[[OpenSSL]]
--[[ASP.NET]]
--[[ASP.NET Core]]

* 目次 [#s97f0756]
#contents

*概要 [#qaed2733]
-「[[Certificate Binding>OAuth 2.0 Mutual TLS Client Authentication and Certificate Bound Access Tokens]]」で必要になったため。

-開発環境で設定する場合は、1台の中で、
--[[クライアント設定>#feec9754]]と
--[[サーバ設定>#mc2bd0a9]]の

>両方を行う必要がある。

*クラアント [#feec9754]
クラアントがサーバにクライアント証明書を渡すよう構成する。
クラアントがサーバに[[クライアント証明書>#l5b15ad7]]を渡すよう構成する。

**Browser [#p631388a]

***Windows [#aa5c5ac8]
-Windows版 - cybozu.com ヘルプ~
https://jp.cybozu.help/ja/settings/browser/certificate/windows.html

***Mac [#j49a6519]
-Mac版 - cybozu.com ヘルプ~
https://jp.cybozu.help/ja/settings/browser/certificate/mac.html

**HttpClient [#z3693422]
-HttpClient でクライアント証明書を設定する方法~
https://qiita.com/volpe28v/items/95efad9e8816b00b348c

-HttpClient, HttpClientHandler, and WebRequestHandler Explained – Henrik's Blog~
https://blogs.msdn.microsoft.com/henrikn/2012/08/07/httpclient-httpclienthandler-and-webrequesthandler-explained/

*サーバ [#mc2bd0a9]
-サーバがクラアントからクライアント証明書を受けるよう構成する。
-クライアント証明書はWeb -> AP にHTTPヘッダで渡される。
-サーバがクラアントから[[クライアント証明書>#l5b15ad7]]を受けるよう構成する。
-[[クライアント証明書>証明書#c42748a0]]はWeb -> AP にHTTPヘッダで渡される。
--例えは、Azure Web Appsでは、X-ARR-ClientCertヘッダを使用して渡される。
--他の中間層では、X-Client-Certヘッダなどが使用されるらしい。

**Windows [#l60b6ef3]

***IIS [#ra97f2fb]
-IISでのクライアント証明書利用設定入門~
https://rms.ne.jp/howto/basis/iis_client_cert.html

***[[IIS Express]] [#sf697402]
[[applicationhost.config>IIS Express#wb65ed64]]に以下の様な設定を行う。

 <security>
   <access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
   <iisClientCertificateMappingAuthentication enabled="true">
   </iisClientCertificateMappingAuthentication>
   ...
   <authentication>
     <iisClientCertificateMappingAuthentication enabled="true">
     </iisClientCertificateMappingAuthentication>
   ...
 </security>

-参考
--How to Configure IIS Express to Accept SSL Client Certificates – Improve & Repeat~
https://improveandrepeat.com/2017/07/how-to-configure-iis-express-to-accept-ssl-client-certificates/

***Kestrel [#p9ce7b3a]
-Microsoft Docs
--ASP.NET Core での HTTPS を適用します。~
https://docs.microsoft.com/ja-jp/aspnet/core/security/enforcing-ssl
--ASP.NET Core への Kestrel Web サーバーの実装~
https://docs.microsoft.com/ja-jp/aspnet/core/fundamentals/servers/kestrel

-ASP.NET~
https://github.com/aspnet
--Docs
---How to setup the dev certificate when using Docker in development · Issue #6199~
https://github.com/aspnet/Docs/issues/6199
--KestrelHttpServer
---How to set ClientCertificateMode in core 2.0? · Issue #2005~
https://github.com/aspnet/KestrelHttpServer/issues/2005

**Linux [#j3c448da]

***Kestrel [#ba2ca68f]

***Apache [#gc31d162]

***nginx [#ed5bd83c]

**[[ASP.NET]] [#cc51cb9d]

-Azure WebSitesでClientCertificateを取得するためのコードと設定~
https://qiita.com/higty/items/e0d2e1331bded9820aff

***Web Forms [#vf7ea04f]
-Page
 // System.Web.HttpRequest
 HttpClientCertificate cs = Request.ClientCertificate;

***MVC [#c3f7530a]
-Controller
 // System.Web.HttpRequestBase
 HttpClientCertificate cs = Request.ClientCertificate;

***WebAPI [#n456fa38]
-ApiControler
 // System.Net.Http.HttpRequestMessage
 // System.Net.Http.HttpRequestMessageExtensions
 X509Certificate2 cs = Request.GetClientCertificate();

**[[ASP.NET Core]] [#g106b2cf]
-現時点では、APIは用意されていない模様。
-netstandard2.0時点では、APIは用意されていない模様。

--Azure Web App Client Certificate Authentication with ASP.NET Core | Kirk Evans Blog~
--参考
---Azure Web App Client Certificate Authentication with ASP.NET Core | Kirk Evans Blog~
https://blogs.msdn.microsoft.com/kaevans/2016/04/13/azure-web-app-client-certificate-authentication-with-asp-net-core-2/

--Azure Web Apps がクライアント証明書に対応したので自己署名証明書で試してみた - しばやん雑記~
---Azure Web Apps がクライアント証明書に対応したので自己署名証明書で試してみた - しばやん雑記~
https://blog.shibayan.jp/entry/20150706/1436150053

-Web-APの連携が必要なので
--IISに限定される.netには実装されているが、
--netcoreappには実装されていない
--(HTTPヘッダの標準が無いため、)Web-APの連携が必要なので
---IISに限定される.netには実装されているが、
---netcoreappには実装されていない。

>みたいなコトだろうか?
>みたいなコトなのだろうか?

-netstandard2.1で、実装された模様。

***MVC [#qeec2d94]

 // Microsoft.AspNetCore.Http.HttpRequest
 X509Certificate2 x509 = Request.HttpContext.Connection.ClientCertificate;

***WebAPI [#g8c7e6f8]
-

**証明書 [#l5b15ad7]
*[[クライアント証明書>証明書#c42748a0]] [#l5b15ad7]

***[[OpenSSL]] [#qd1c0dfa]
**[[OpenSSL]] [#qd1c0dfa]
以下で生成してみたが、ダメ。

-クライアント証明書の作り方 | 日々雑記~
http://y-yagi.tumblr.com/post/18179788088/%E3%82%AF%E3%83%A9%E3%82%A4%E3%82%A2%E3%83%B3%E3%83%88%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%AE%E4%BD%9C%E3%82%8A%E6%96%B9

***Visual Studio [#xf9f4c00]
**Visual Studio [#xf9f4c00]

-Visual Studioの署名で作成したPFXであれば利用可能だった。

-[[OpenSSL>#qd1c0dfa]]と何が違うか不明。何か属性が足りてないのか?

-一応、使用するには、
--[[ブラウザから使用できるように設定する。>#p631388a]]

--サーバから使用できるように設定する。
---[[Windows>#l60b6ef3]]
---[[Linux>#j3c448da]]

>両方を行う必要がある。

*参考 [#ddcad5a7]

**[[自己署名証明書の場合>OAuth 2.0 Mutual TLS Client Authentication and Certificate Bound Access Tokens#k39dceb1]] [#k4ba048d]

***クライアント側 [#v37d8aa1]

-[Unity/C#]WWW/HttpWebRequestにおける~
中間者攻撃の危険性を考慮した通信プログラムまとめ - Qiita~
https://qiita.com/harmegiddo/items/b72ca4f430292251c8a6

***サーバー側 [#z45e31a0]
Bouncy CastleでHTTPヘッダから取得したpemを読む的なイメージでイイのでは?

----
Tags: [[:.NET開発]], [[:.NET Core]], [[:ASP.NET]], [[:ASP.NET MVC]], [[:セキュリティ]], [[:暗号化]], [[:証明書]]


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS