Skip to content

A .NET facility to create an OCSP Responder. Written in C# under netstandard it has support for .NET Full and .NET Core

License

Notifications You must be signed in to change notification settings

gabrielcalegari/OCSPResponder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCSPResponder

A .NET facility to create an OCSP Responder

Build status NuGet Version License

What is this?

OCSPResponder is a library written in C# that enables you to easily create an OCSP Responder in .NET. All you need is to implement an interface for the CA/Authorized Responder. It follows the OCSP protocol defined in RFC 6960.

How do I use it?

.NET Core

  1. Install OCSPResponder.AspNetCore via NuGet. This package contains OCSPResponder.Core as dependency.
  2. Implement the IOcspResponderRepository interface for your CA.
  3. Configure in your Dependency Injector to use the class OcspResponder for the interface IOcspResponder.
  4. Configure in your Dependency Injector to use the class that you implemented for the interface IOcspResponderRepository.
  5. Create a WebAPI Controller and call OcspResponder.Respond() passing the HttpRequest.ToOcspRequest().
  6. Done! You've been configured your OCSP Responder.

Example

/Controllers/OcspController.cs

[Route("api/ocsp")]
public class OcspController : Controller
{
    [HttpGet]
    public async Task<IActionResult> Get(string encoded)
    {
        var ocspHttpRequest = await Request.ToOcspHttpRequest();
        var ocspHttpResponse =  await OcspResponder.Respond(ocspHttpRequest);
        return new OcspActionResult(ocspHttpResponse);
    }

    [HttpPost]
    public async Task<IActionResult> Post()
    {
        var ocspHttpRequest = await Request.ToOcspHttpRequest();
        var ocspHttpResponse = await OcspResponder.Respond(ocspHttpRequest);
        return new OcspActionResult(ocspHttpResponse);
    }

    private IOcspResponder OcspResponder { get; }

    public OcspController(IOcspResponder ocspResponder)
    {
        OcspResponder = ocspResponder;
    }
}

.NET Framework

  1. Install OCSPResponder.Core via NuGet.
  2. Implement the IOcspResponderRepository interface for your CA.
  3. Configure in your Dependency Injector to use the class OcspResponder for the interface IOcspResponder.
  4. Configure in your Dependency Injector to use the class that you implemented for the interface IOcspResponderRepository.
  5. Create a WebAPI Controller and call OcspResponder.Respond() passing the HttpRequestMessage.ToOcspHttpRequest().
  6. Done! You've been configured your OCSP Responder.

Example

/Controllers/OcspController.cs

[RoutePrefix("api/ocsp")]
public class OcspController : Controller
{
    [Route("{encoded}"]
    public Task<HttpResponseMessage> Get(string encoded)
    {
        var ocspHttpResponse = await OcspResponder.Respond(Request.ToOcspHttpRequest());
        return ocspHttpResponse.toHttpResponseMessage();
    }
    
    [Route("")]
    public Task<HttpResponseMessage> Post()
    {
        var ocspHttpResponse = await OcspResponder.Respond(Request.ToOcspHttpRequest());
        return ocspHttpResponse.toHttpResponseMessage();
    }
    
    private IOcspResponder OcspResponder { get; }
    
    public OcspController(IOcspResponder ocspResponder)
    {
        OcspResponder = ocspResponder;
    }
}

License

Code by Gabriel Calegari. Copyright 2018 Gabriel Calegari.

This library is intended to be used in both open-source and commercial environments. It is under Apache 2.0 license.

Refer to the LICENSE for detailed information.

Any questions, comments or additions?

If you have a feature request or bug report, leave an issue on the issues page or send a pull request. For general questions and comments, use the StackOverflow forum.

About

A .NET facility to create an OCSP Responder. Written in C# under netstandard it has support for .NET Full and .NET Core

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages