GithubHelp home page GithubHelp logo

gabrielcalegari / ocspresponder Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 5.0 48 KB

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

License: Apache License 2.0

C# 100.00%
ocsp-responder ocsp csharp csharp-library netstandard sharp ocsp-stapling ocsp-responses ocsp-request

ocspresponder's Introduction

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.

ocspresponder's People

Contributors

gabrielcalegari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ocspresponder's Issues

How are SerialNumber Values Derived

Hello All,

I'm trying to figure how the SerialExists & SerialIsRevoked method derive the 'serial' argument value. So for example, when my certificate has a hexadecimal serial number value of '9dd919ba4ead18b78df7382112f9fb6953da22c5', I get the value of '901153053931671044175307656606196330260573332165' for the 'serial' argument.

Also, is there a reason why the value had to be altered? Can I configure the product to return just the hexadecimal value instead of these large numbers?

  • Rashad Rivera

Example

Do you can give an example?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.