Coder Social home page Coder Social logo

mbw.client.ssllabslib's Introduction

SSL Labs API client for .NET

This is an SSL Labs API client wrapper for SSLLabs asssesment tool, based on the official SSL Labs API Documentation

Generic Build Nuget

Installation

The easiest way to get the library is to use Nuget. The library has been published here, and is also available at Github in source form. The following Nuget command will fetch the package for you.

Install-Package MBW.Client.SslLabsLib

Example usage

The SSL Labs API is built up around a polling method, where you regularly poll the API for the status on an ongoing assesment. An example client that fetches a result for Google.com is below:

SslLabsClient client = new SslLabsClient();
HostInfo analysis = await client.Analyze("google.com");

Console.WriteLine("TLS Grade of Google.com");
Console.WriteLine(analysis.Endpoints.First().Grade);

A simple client that will initiate a new scan, and poll for the results is below.

SslLabsClient client = new SslLabsClient();
TimeSpan waitTime = TimeSpan.FromSeconds(20);
string target = "www.dr.dk";

HostInfo analysis = await client.Analyze(target, startNew: true);
while (analysis.Status != AnalysisStatus.READY)
{
    Console.WriteLine($"Last status was {analysis.Status}, waiting {waitTime}");
    await Task.Delay(waitTime);

    // Note that Ssllabs tracks progress per endpoint that a domain resolves to
    analysis = await client.Analyze(target, all: AnalysisAll.WhenDone);
    Console.WriteLine($"Current status: {analysis.Status}, progresses: {string.Join(", ", analysis.Endpoints.Select(x => x.Progress + "%"))}");

    if (analysis.Endpoints.Select(s => s.Progress).Min() > 80)
        waitTime = TimeSpan.FromSeconds(5);
}

Console.WriteLine($"TLS Grade of {target}: {analysis.Endpoints.First().Grade}");

mbw.client.ssllabslib's People

Contributors

augustg avatar lordmike avatar mike-csis avatar

Watchers

 avatar

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.