c# - Configuring SSL on ASP.NET Self-Hosted Web API -
i'm creating self-hosted web api service. secure it, i've studied , implemented this article, generated local ssl certificate using makecert , service authenticated , generates tokens fine, if i'm using
http://localhost/webapi/authentication/authenticate
link, when try access service using https, following on firefox:
ssl_error_rx_record_too_long
and same request fiddler shows me:
http/1.1 502 fiddler - connection failed date: mon, 26 aug 2013 10:44:27 gmt content-type: text/html; charset=utf-8 connection: close timestamp: 13:44:27.433
[fiddler] socket connection localhost failed.
failed negotiate https connection server.fiddler.network.https> failed secure existing connection localhost. handshake failed due unexpected packet format..
my self-host configuration:
private httpselfhostserver _server; private extendedhttpsselfhostconfiguration _config; public const string serviceaddress = "https://localhost/webapi"; _config = new extendedhttpsselfhostconfiguration(serviceaddress); _server = new httpselfhostserver(_config); _server.openasync();
where extendedhttpselfhostconfiguration taken this post is:
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); } }
what i'm missing? in advance!
according this blog post i've figured out, should create ssl certificate , assign specific port (:99 in case).
i've created locally signed ssl. got it's thumbprint , applicationid. using cmd command netsh (in pre win7 systems there httpcfg tool), i've assigned certificate port
netsh http add sslcert ipport=0.0.0.0:99 certhash=3e49906c01a774c888231e5092077d3d855a6861 appid={2d6059b2-cccb-4a83-ae08-8ce209c2c5c1}
, certhash = ssl thumbprint, , appid = applicationid i've copied earlier.
that's it, i'm able make https requests!
Comments
Post a Comment