Skip to content

Latest commit

 

History

History
433 lines (350 loc) · 15.3 KB

CertificatesApi.md

File metadata and controls

433 lines (350 loc) · 15.3 KB

Com.Lab5e.Span.Api.CertificatesApi

All URIs are relative to https://api.lab5e.com

Method HTTP request Description
CreateCertificate POST /span/collections/{collectionId}/certificates/create Create certificate
RetrieveCertificateChain GET /span/collections/{collectionId}/certificates Get certificate chain
SignCertificate POST /span/collections/{collectionId}/certificates/sign Sign certificate
VerifyCertificate POST /span/collections/{collectionId}/certificates/verify Verify certificate

CreateCertificate

CreateCertificateResponse CreateCertificate (string collectionId, CreateCertificateBody body)

Create certificate

Create a new device or gateway (client) certificate for an internet-connected device. The devices will use this client certificate to authenticate when sending data via the Internet endpoint. This will create a X509 client certificate with an ECC public key. The key is not stored by the service so keep it in a secure place once it is downloaded. The returned certificate will be valid for 14 days. The key for the certificate is your own responsibility. The client certificate is used in both the TLS, DTLS and gRPC service endpoints.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
using Com.Lab5e.Span.Model;

namespace Example
{
    public class CreateCertificateExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "https://api.lab5e.com";
            // Configure API key authorization: APIToken
            config.AddApiKey("X-API-Token", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("X-API-Token", "Bearer");

            var apiInstance = new CertificatesApi(config);
            var collectionId = "collectionId_example";  // string | 
            var body = new CreateCertificateBody(); // CreateCertificateBody | 

            try
            {
                // Create certificate
                CreateCertificateResponse result = apiInstance.CreateCertificate(collectionId, body);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling CertificatesApi.CreateCertificate: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the CreateCertificateWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Create certificate
    ApiResponse<CreateCertificateResponse> response = apiInstance.CreateCertificateWithHttpInfo(collectionId, body);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling CertificatesApi.CreateCertificateWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
collectionId string
body CreateCertificateBody

Return type

CreateCertificateResponse

Authorization

APIToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
201 It's created. -
400 The request has an error. -
401 You can't touch this -
404 Couldn't find the resource. -
409 There's a resource conflict here. -
500 I'm sorry. We are broken -
0 An unexpected error response. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

RetrieveCertificateChain

CertificateChainResponse RetrieveCertificateChain (string collectionId, string? gatewayId = null, string? deviceId = null)

Get certificate chain

Get the certificate chain for the root CA and intermediate certificates used by the device, gateway and server certificates. It is highly recommended to verify the server certificate when sending data to avoid any man-in-the-middle attacks. This chain will contain all required certificates needed to verify the client certificate.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
using Com.Lab5e.Span.Model;

namespace Example
{
    public class RetrieveCertificateChainExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "https://api.lab5e.com";
            // Configure API key authorization: APIToken
            config.AddApiKey("X-API-Token", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("X-API-Token", "Bearer");

            var apiInstance = new CertificatesApi(config);
            var collectionId = "collectionId_example";  // string | 
            var gatewayId = "gatewayId_example";  // string? |  (optional) 
            var deviceId = "deviceId_example";  // string? |  (optional) 

            try
            {
                // Get certificate chain
                CertificateChainResponse result = apiInstance.RetrieveCertificateChain(collectionId, gatewayId, deviceId);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling CertificatesApi.RetrieveCertificateChain: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the RetrieveCertificateChainWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Get certificate chain
    ApiResponse<CertificateChainResponse> response = apiInstance.RetrieveCertificateChainWithHttpInfo(collectionId, gatewayId, deviceId);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling CertificatesApi.RetrieveCertificateChainWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
collectionId string
gatewayId string? [optional]
deviceId string? [optional]

Return type

CertificateChainResponse

Authorization

APIToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
201 It's created. -
400 The request has an error. -
401 You can't touch this -
404 Couldn't find the resource. -
409 There's a resource conflict here. -
500 I'm sorry. We are broken -
0 An unexpected error response. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

SignCertificate

SignCertificateResponse SignCertificate (string collectionId, SignCertificateBody body)

Sign certificate

Sign a device or gateway (aka client) certificate. The certificate is a X509 Certificate signing request PEM encoded. The certificate will be valid for 14 days and must be renewed.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
using Com.Lab5e.Span.Model;

namespace Example
{
    public class SignCertificateExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "https://api.lab5e.com";
            // Configure API key authorization: APIToken
            config.AddApiKey("X-API-Token", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("X-API-Token", "Bearer");

            var apiInstance = new CertificatesApi(config);
            var collectionId = "collectionId_example";  // string | 
            var body = new SignCertificateBody(); // SignCertificateBody | 

            try
            {
                // Sign certificate
                SignCertificateResponse result = apiInstance.SignCertificate(collectionId, body);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling CertificatesApi.SignCertificate: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the SignCertificateWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Sign certificate
    ApiResponse<SignCertificateResponse> response = apiInstance.SignCertificateWithHttpInfo(collectionId, body);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling CertificatesApi.SignCertificateWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
collectionId string
body SignCertificateBody

Return type

SignCertificateResponse

Authorization

APIToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
201 It's created. -
400 The request has an error. -
401 You can't touch this -
404 Couldn't find the resource. -
409 There's a resource conflict here. -
500 I'm sorry. We are broken -
0 An unexpected error response. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

VerifyCertificate

VerifyCertificateResponse VerifyCertificate (string collectionId, VerifyCertificateBody body)

Verify certificate

Verify client certificate. If a client certificate fails it can be tricky to pinpoint exactly why the certificate isn't accepted. This resource validates the client certificate and returns the error in plain text.

Example

using System.Collections.Generic;
using System.Diagnostics;
using Com.Lab5e.Span.Api;
using Com.Lab5e.Span.Client;
using Com.Lab5e.Span.Model;

namespace Example
{
    public class VerifyCertificateExample
    {
        public static void Main()
        {
            Configuration config = new Configuration();
            config.BasePath = "https://api.lab5e.com";
            // Configure API key authorization: APIToken
            config.AddApiKey("X-API-Token", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.AddApiKeyPrefix("X-API-Token", "Bearer");

            var apiInstance = new CertificatesApi(config);
            var collectionId = "collectionId_example";  // string | 
            var body = new VerifyCertificateBody(); // VerifyCertificateBody | 

            try
            {
                // Verify certificate
                VerifyCertificateResponse result = apiInstance.VerifyCertificate(collectionId, body);
                Debug.WriteLine(result);
            }
            catch (ApiException  e)
            {
                Debug.Print("Exception when calling CertificatesApi.VerifyCertificate: " + e.Message);
                Debug.Print("Status Code: " + e.ErrorCode);
                Debug.Print(e.StackTrace);
            }
        }
    }
}

Using the VerifyCertificateWithHttpInfo variant

This returns an ApiResponse object which contains the response data, status code and headers.

try
{
    // Verify certificate
    ApiResponse<VerifyCertificateResponse> response = apiInstance.VerifyCertificateWithHttpInfo(collectionId, body);
    Debug.Write("Status Code: " + response.StatusCode);
    Debug.Write("Response Headers: " + response.Headers);
    Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
    Debug.Print("Exception when calling CertificatesApi.VerifyCertificateWithHttpInfo: " + e.Message);
    Debug.Print("Status Code: " + e.ErrorCode);
    Debug.Print(e.StackTrace);
}

Parameters

Name Type Description Notes
collectionId string
body VerifyCertificateBody

Return type

VerifyCertificateResponse

Authorization

APIToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
201 It's created. -
400 The request has an error. -
401 You can't touch this -
404 Couldn't find the resource. -
409 There's a resource conflict here. -
500 I'm sorry. We are broken -
0 An unexpected error response. -

[Back to top] [Back to API list] [Back to Model list] [Back to README]