4

現在、開発サーバーに IIS Express を使用する ASP.Net MVC 3 ECCOMERCE アプリを構築しています。

アプリ経由で支払いを受け付けているため、チェックアウト プロセスに SSL 接続を適用する必要があります。

IIS Express で使用する自己署名 SSL 証明書をセットアップする方法に関する Scott Hanselman のよく書かれた記事に従った後、両方から自分のサイトにアクセスできます。

再起動するまで、これはすべて肉汁です。(何らかの理由で) 再起動するたびに、次のコマンドを再度実行する必要があるようです。

netsh http delete sslcert ipport=0.0.0.0:443
netsh http add sslcert ipport=0.0.0.0:443 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=<thumbprint from Certificate Manager>

生成された証明書のエクスポートとインポート、および個人ストアから信頼されたルート証明機関への証明書のドラッグを試みました。どちらも役に立たない。

誰にもアイデアはありますか?

4

4 に答える 4

1

この問題は、 http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspxのコメントで何人かの人々によって言及されてい ます。

最後のコメントは次のとおりです。

自己署名証明書を Personal から Trusted Root CA ディレクトリに移動すると、開発者がマシンを再起動した後に SSL が機能しなくなるという問題が発生すると思います。(どのように発生するかはわかりませんが、一貫して発生します。)最終的に、自己署名証明書を信頼できるルートディレクトリにエクスポートして再インポートすることで、この問題を回避します(単純にドラッグするのではなく)。これで、自己署名証明書が考慮され、マシンを再起動するたびに IIS Express を再インストール/修復する必要がなくなりました。

于 2013-09-30T15:00:10.867 に答える
0

証明書をcurrentuserまたはLocalMachineストアにインポートしましたか?CurrentUserストアに証明書をインポートすると、この問題が発生するようです。次のスレッドを ご覧くださいhttp://social.msdn.microsoft.com/Forums/en/wcf/thread/9e560c64-c53a-4de5-80d5-d2231ba8bcb1

于 2012-03-16T03:16:49.337 に答える
0

以下は、既存の証明書を削除し、新しい自己署名証明書を作成して IIS 8.0 Express にバインドできる PowerShell スクリプトです。実行するために起動する PowerShell は、[管理者として実行] を使用する必要があります。これを使用して、キー サイズをデフォルトの 1024 ビットから 4096 ビットに増やしています。

# NOTE: This script MUST use Run as Administrator to work correctly.
# This script works with IIS 8.0 Express.
$currentIdentity=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$currentPrincipal=new-object System.Security.Principal.WindowsPrincipal($currentIdentity)
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator

if (($currentPrincipal -eq $null) -or ($currentPrincipal.IsInRole($adminRole) -eq $false))
{
    Write-Error "This script must be run with Admnistrator privileges."
    exit
}

$iisExpressAppId = "{214124cd-d05b-4309-9af9-9caa44b2b74a}"
$iisExpressCertFriendlyName = "IIS Express Development Certificate"

# Get the current IIS Express certificate and remove it if it exists
$iisExpressCert = Get-ChildItem Cert:\LocalMachine\My | ? { $_.FriendlyName -eq $iisExpressCertFriendlyName }

if ($iisExpressCert -ne $null)
{
    Remove-Item $iisExpressCert.PSPath
}

# Create a new self-signed server certificate with a 4096-bit key
& "C:\Program Files (x86)\Windows Kits\8.1\bin\x86\makecert.exe" -r -pe -n "CN=localhost" -m 60 -ss My -sr LocalMachine -sky Exchange -eku 1.3.6.1.5.5.7.3.1 -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -a sha512 -len 4096

# Get the newly generated server certificate
$iisExpressCert = Get-ChildItem Cert:\LocalMachine\My | ? { $_.Subject -eq "CN=localhost" -and [DateTime]::Parse($_.GetEffectiveDateString()).Date -eq [DateTime]::Today }

if ($iisExpressCert -ne $null)
{
    # Change the friendly name of the new certificate.
    $iisExpressCert.FriendlyName = $iisExpressCertFriendlyName

    # Iterate through the IIS Express ports removing the old certificate
    # and adding the new one.
    44300..44399 | foreach {
        & "C:\Windows\System32\netsh.exe" http delete sslcert ipport=0.0.0.0:$($_)
        & "C:\Windows\System32\netsh.exe" http add sslcert ipport=0.0.0.0:$($_) certhash=$($iisExpressCert.Thumbprint) appid=$($iisExpressAppId)
    }
}

<# Remove comment tags only if you intend to trust the self-signed cert.
# Adds the Public Certificate to the Trusted Root Certification Authorities.
$iisExpressPublicCert = Get-ChildItem Cert:\LocalMachine\AuthRoot | ? { $_.FriendlyName -eq $iisExpressCertFriendlyName }

if ($iisExpressPublicCert -ne $null)
{
    Remove-Item $iisExpressPublicCert.PSPath
}

$iisExpressPublicCert = New-Object "System.Security.Cryptography.X509Certificates.X509Certificate2" @(,$iisExpressCert.Export("Cert"))
$iisExpressPublicCert.FriendlyName = $iisExpressCertFriendlyName

$trustedCertStore = Get-Item Cert:\LocalMachine\AuthRoot
$trustedCertStore.Open("ReadWrite")
$trustedCertStore.Add($iisExpressPublicCert)
$trustedCertStore.Close()
#>
于 2015-10-08T21:37:10.007 に答える
0

いくつかのコメント。

まず、次のコマンドを使用して、MMC を使用せずに IIS Express サムプリントにアクセスできます。

powershell -command "& {get-childitem -path cert:\localmachine\my | where-object {$ .FriendlyName -match 'IIS Express Development Certificate'} | % { $ .Thumbprint}}"

http://msdn.microsoft.com/en-us/library/ms733791.aspxで説明されているように、コマンドで拇印を使用して netsh します。上記の powershell 手法を使用して、IIS Express の特定のインストールに適した netsh コマンドを作成できます。

上記のコマンドに追加して、ポート 443 の正しい netsh コマンドを出力してみましょう。

powershell -command "& {get-childitem -path cert:\localmachine\my | where-object {$ .FriendlyName -match 'IIS Express Development Certificate'} | % { 'netsh http add sslcert ipport=0.0.0.0:443 appid ={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash='+$ .拇印}}"

これにより、使用する必要がある完全な netsh コマンドが表示されます。コピーして貼り付けて、自分で呼び出すことができます。** | を追加することもできます。cmd.exe** を上記のコマンドに追加して、自動的に呼び出します。それをしましょう。以下は、ローカル 443 ポートをローカル IIS Express 証明書にバインドするように設定するために、管理者コマンド プロンプトにコピー/貼り付けする準備ができている上記の PowerShell コマンドです。

powershell -command "& {get-childitem -path cert:\localmachine\my | where-object {$ .FriendlyName -match 'IIS Express Development Certificate'} | % { 'netsh http add sslcert ipport=0.0.0.0:443 appid ={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash='+$ .拇印}}" | cmd.exe

于 2014-06-11T20:20:13.830 に答える