13

I use Asp.net web APIs to provide apis to client (iphone, android, mac os,web,windows,...). I want to implement some API with more security, which I prevent some other understand the parameter in the link (in case they hack the link)

My question is: Can I use Https/SSL for this? Is it enough secure? If yes, Should I install any thing at client side to implement this?

Thanks

1 Answer 1

15

It depends on where you are going to host your ASP.NET Web API application. If you are going to host it under IIS, you don't need to do anything special other than configuring SSL through IIS.

One thing you should do IMO is to force HTTPS through your application. You can implement this with different ways (such as IIS URL Redirect module, etc.) but you can also do this at the application level with a message handler:

public class RequireHttpsMessageHandler : DelegatingHandler {

    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {

        if (request.RequestUri.Scheme != Uri.UriSchemeHttps) {

            var forbiddenResponse = request.CreateResponse(HttpStatusCode.Forbidden);
            forbiddenResponse.ReasonPhrase = "SSL Required";
            return Task.FromResult<HttpResponseMessage>(forbiddenResponse);
        }

        return base.SendAsync(request, cancellationToken);
    }
}

HttpClient also supports SSL just like any other .NET web clients. Have a look at this article: http://blogs.msdn.com/b/henrikn/archive/2012/08/07/httpclient-httpclienthandler-and-httpwebrequesthandler.aspx

Sign up to request clarification or add additional context in comments.

3 Comments

I will host my Web API application at AWS. I think I can install and config IIS for it, right?
@NguyenMinhBinh not sure what kind of access AWS gives you in terms of IIS but if you have full control over your VM, sure.
@NguyenMinhBinh also, during development time, this post might help as well: tugberkugurlu.com/archive/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.