6

C# を使用して (コマンド ラインを実行せずに) アプリケーションから netsh で clientcertnegotiation=enable を設定するのと同等のことを実現するにはどうすればよいですか。

netsh http add sslcert ipport=0.0.0.0:8000 certhash=2064a43f429fe97746ce0c1c9adcd4ea93415f6d appid={4dc3e181-e14b-4a21-b022-59fc669b0914} clientcertnegotiation=enable

次のコードは、証明書を正常に追加します

using (var manager = new ServerManager())
        {
            var siteBindings = from s1 in manager.Sites
                               from b1 in s1.Bindings
                               where b1.Protocol.Equals("https")
                               select new {SiteName = s1.Name, Binding = b1};

            foreach (var siteBinding in siteBindings)
            {
                siteBinding.Binding.CertificateHash = cert.GetCertHash();
            }

            // This is correctly setting the values on the Ssl Cert configuration section in IIS
            var config = manager.GetApplicationHostConfiguration();
            var accessSection = config.GetSection("system.webServer/security/access", "WebActivationService");
            accessSection["sslFlags"] = @"Ssl, SslRequireCert";

            manager.CommitChanges();
        }

しかし、netsh http show sslcert を実行すると、ネゴシエート クライアント証明書の設定が解除されたことが示されます。

IP:port                 : 0.0.0.0:8000
Certificate Hash        : 2064a43f429fe97746ce0c1c9adcd4ea93415f6d
Application ID          : {4dc3e181-e14b-4a21-b022-59fc669b0914}
Certificate Store Name  : MY
Verify Client Certificate Revocation    : Enabled
Verify Revocation Using Cached Client Certificate Only    : Disabled
Usage Check    : Enabled
Revocation Freshness Time : 0
URL Retrieval Timeout   : 0
Ctl Identifier          : (null)
Ctl Store Name          : (null)
DS Mapper Usage    : Disabled
Negotiate Client Certificate    : Disabled

バインディングを削除して再作成しても同じ効果があります

4

3 に答える 3

2

WindowsServer2003から+以下を使用できます。

ULONG HttpSetServiceConfiguration(
  __in  HANDLE ServiceHandle,
  __in  HTTP_SERVICE_CONFIG_ID ConfigId,
  __in  PVOID pConfigInformation,
  __in  ULONG ConfigInformationLength,
  __in  LPOVERLAPPED pOverlapped
);

http://msdn.microsoft.com/en-us/library/windows/desktop/aa364503(v=vs.85).aspx

于 2012-02-16T16:14:45.417 に答える
0

https://www.iis.net/ConfigReference/system.applicationHost/sites/site/ftpServer/security/sslClientCertificatesで説明されている例を使用して、クライアント証明書の確認を有効にします。

非クライアント認証接続を失敗させるには、clientCertificatePolicy を CertRequire に設定する必要があります。証明書を実際の Windows ユーザーにマップするかどうかに応じて、useActiveDirectoryMapping を適切な値に設定する必要があります。

于 2011-08-10T16:04:08.553 に答える
0

私には、いくつかの重要な設定が欠けているようです...これを行う方法に関するコードサンプルについては、いくつかの説明を参照してください http://www.iis.net/ConfigReference/system.webServer/security/authentication/iisClientCertificateMappingAuthentication#006

于 2011-08-10T13:11:27.157 に答える