セルフホステッド Web API サービスを作成しています。それを保護するために、私はこの記事を研究して実装し、makecert を使用してローカル SSL 証明書を正常に生成し、サービスを認証してトークンを正常に生成しました (使用している場合)。
http://localhost/webapi/authentication/authenticate
リンクですが、HTTPS を使用してサービスにアクセスしようとすると、Firefox で次のようになります。
ssl_error_rx_record_too_long
同じリクエストに対して、Fiddler は次のように表示します。
HTTP/1.1 502 Fiddler - 接続失敗日付: 2013 年 8 月 26 日月曜日 10:44:27 GMT コンテンツ タイプ: text/html; charset=UTF-8 接続: 閉じる タイムスタンプ: 13:44:27.433
[Fiddler] localhost へのソケット接続に失敗しました。
server.fiddler.network.https との HTTPS 接続のネゴシエーションに失敗しました > localhost の既存の接続を保護できませんでした。予期しないパケット形式のため、ハンドシェイクに失敗しました..
私の自己ホスト構成:
private HttpSelfHostServer _server;
private ExtendedHttpsSelfHostConfiguration _config;
public const string ServiceAddress = "https://localhost/webapi";
_config = new ExtendedHttpsSelfHostConfiguration(ServiceAddress);
_server = new HttpSelfHostServer(_config);
_server.OpenAsync();
この投稿から取得した ExtendedHttpSelfHostConfigurationは次のとおりです。
public class ExtendedHttpSelfHostConfiguration : HttpSelfHostConfiguration
{
public ExtendedHttpSelfHostConfiguration(string baseAddress) : base(baseAddress) { }
public ExtendedHttpSelfHostConfiguration(Uri baseAddress) : base(baseAddress) { }
protected override BindingParameterCollection OnConfigureBinding(HttpBinding httpBinding)
{
if (BaseAddress.ToString().ToLower().Contains("https://"))
{
httpBinding.Security.Mode = HttpBindingSecurityMode.Transport;
}
return base.OnConfigureBinding(httpBinding);
}
}
私は何が欠けていますか?前もって感謝します!