Skip to content

Latest commit

 

History

History
435 lines (327 loc) · 13.4 KB

V1CaApi.md

File metadata and controls

435 lines (327 loc) · 13.4 KB

V1CaApi

All URIs are relative to http://localhost/ejbca/ejbca-rest-api

Method HTTP request Description
createCrl POST /v1/ca/{issuer_dn}/createcrl Create CRL(main, partition and delta) issued by this CA
getCertificateAsPem GET /v1/ca/{subject_dn}/certificate/download Get PEM file with the active CA certificate chain
getLatestCrl GET /v1/ca/{issuer_dn}/getLatestCrl Returns the latest CRL issued by this CA
importCrl POST /v1/ca/{issuer_dn}/importcrl Import a certificate revocation list (CRL) for a CA
listCas GET /v1/ca Returns the Response containing the list of CAs with general information per CA as Json
status1 GET /v1/ca/status Get the status of this REST Resource

createCrl

CreateCrlRestResponse createCrl(issuerDn, deltacrl)

Create CRL(main, partition and delta) issued by this CA

Example

// Import classes:
import com.keyfactor.ejbca.client.ApiClient;
import com.keyfactor.ejbca.client.ApiException;
import com.keyfactor.ejbca.client.Configuration;
import com.keyfactor.ejbca.client.model.*;
import com.keyfactor.ejbca.client.api.V1CaApi;

import java.nio.file.Path;

public class Example {
  public static void main(String[] args) {
    // Set base path to EJBCA REST API
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost/ejbca/ejbca-rest-api");

    // Retrieve client certificate and key
    Path cert = Paths.get("path/to/clientcertificate");
    Path key = Paths.get("path/to/key");
    defaultClient.setClientCert(cert, key);

    V1CaApi apiInstance = new V1CaApi(defaultClient);
    String issuerDn = "issuerDn_example"; // String | the CRL issuers DN (CAs subject DN)
    Boolean deltacrl = false; // Boolean | true to also create the deltaCRL, false to only create the base CRL
    try {
      CreateCrlRestResponse result = apiInstance.createCrl(issuerDn, deltacrl);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling V1CaApi#createCrl");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
issuerDn String the CRL issuers DN (CAs subject DN)
deltacrl Boolean true to also create the deltaCRL, false to only create the base CRL [optional] [default to false]

Return type

CreateCrlRestResponse

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 successful operation -

getCertificateAsPem

getCertificateAsPem(subjectDn)

Get PEM file with the active CA certificate chain

Example

// Import classes:
import com.keyfactor.ejbca.client.ApiClient;
import com.keyfactor.ejbca.client.ApiException;
import com.keyfactor.ejbca.client.Configuration;
import com.keyfactor.ejbca.client.model.*;
import com.keyfactor.ejbca.client.api.V1CaApi;

import java.nio.file.Path;

public class Example {
  public static void main(String[] args) {
    // Set base path to EJBCA REST API
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost/ejbca/ejbca-rest-api");

    // Retrieve client certificate and key
    Path cert = Paths.get("path/to/clientcertificate");
    Path key = Paths.get("path/to/key");
    defaultClient.setClientCert(cert, key);

    V1CaApi apiInstance = new V1CaApi(defaultClient);
    String subjectDn = "subjectDn_example"; // String | CAs subject DN
    try {
      apiInstance.getCertificateAsPem(subjectDn);
    } catch (ApiException e) {
      System.err.println("Exception when calling V1CaApi#getCertificateAsPem");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
subjectDn String CAs subject DN

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

HTTP response details

Status code Description Response headers
0 successful operation -

getLatestCrl

CrlRestResponse getLatestCrl(issuerDn, deltaCrl, crlPartitionIndex)

Returns the latest CRL issued by this CA

Example

// Import classes:
import com.keyfactor.ejbca.client.ApiClient;
import com.keyfactor.ejbca.client.ApiException;
import com.keyfactor.ejbca.client.Configuration;
import com.keyfactor.ejbca.client.model.*;
import com.keyfactor.ejbca.client.api.V1CaApi;

import java.nio.file.Path;

public class Example {
  public static void main(String[] args) {
    // Set base path to EJBCA REST API
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost/ejbca/ejbca-rest-api");

    // Retrieve client certificate and key
    Path cert = Paths.get("path/to/clientcertificate");
    Path key = Paths.get("path/to/key");
    defaultClient.setClientCert(cert, key);

    V1CaApi apiInstance = new V1CaApi(defaultClient);
    String issuerDn = "issuerDn_example"; // String | the CRL issuers DN (CAs subject DN)
    Boolean deltaCrl = false; // Boolean | true to get the latest deltaCRL, false to get the latest complete CRL
    Integer crlPartitionIndex = 0; // Integer | the CRL partition index
    try {
      CrlRestResponse result = apiInstance.getLatestCrl(issuerDn, deltaCrl, crlPartitionIndex);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling V1CaApi#getLatestCrl");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
issuerDn String the CRL issuers DN (CAs subject DN)
deltaCrl Boolean true to get the latest deltaCRL, false to get the latest complete CRL [optional] [default to false]
crlPartitionIndex Integer the CRL partition index [optional] [default to 0]

Return type

CrlRestResponse

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 successful operation -

importCrl

importCrl(issuerDn, crlFile, crlPartitionIndex)

Import a certificate revocation list (CRL) for a CA

Example

// Import classes:
import com.keyfactor.ejbca.client.ApiClient;
import com.keyfactor.ejbca.client.ApiException;
import com.keyfactor.ejbca.client.Configuration;
import com.keyfactor.ejbca.client.model.*;
import com.keyfactor.ejbca.client.api.V1CaApi;

import java.nio.file.Path;

public class Example {
  public static void main(String[] args) {
    // Set base path to EJBCA REST API
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost/ejbca/ejbca-rest-api");

    // Retrieve client certificate and key
    Path cert = Paths.get("path/to/clientcertificate");
    Path key = Paths.get("path/to/key");
    defaultClient.setClientCert(cert, key);

    V1CaApi apiInstance = new V1CaApi(defaultClient);
    String issuerDn = "issuerDn_example"; // String | the CRL issuers DN (CAs subject DN)
    File crlFile = new File("/path/to/file"); // File | CRL file in DER format
    Integer crlPartitionIndex = 0; // Integer | CRL partition index
    try {
      apiInstance.importCrl(issuerDn, crlFile, crlPartitionIndex);
    } catch (ApiException e) {
      System.err.println("Exception when calling V1CaApi#importCrl");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
issuerDn String the CRL issuers DN (CAs subject DN)
crlFile File CRL file in DER format [optional]
crlPartitionIndex Integer CRL partition index [optional] [default to 0]

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: Not defined

HTTP response details

Status code Description Response headers
200 CRL file was imported successfully -
400 Error while importing CRL file -

listCas

CaInfosRestResponse listCas()

Returns the Response containing the list of CAs with general information per CA as Json

Returns the Response containing the list of CAs with general information per CA as Json

Example

// Import classes:
import com.keyfactor.ejbca.client.ApiClient;
import com.keyfactor.ejbca.client.ApiException;
import com.keyfactor.ejbca.client.Configuration;
import com.keyfactor.ejbca.client.model.*;
import com.keyfactor.ejbca.client.api.V1CaApi;

import java.nio.file.Path;

public class Example {
  public static void main(String[] args) {
    // Set base path to EJBCA REST API
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost/ejbca/ejbca-rest-api");

    // Retrieve client certificate and key
    Path cert = Paths.get("path/to/clientcertificate");
    Path key = Paths.get("path/to/key");
    defaultClient.setClientCert(cert, key);

    V1CaApi apiInstance = new V1CaApi(defaultClient);
    try {
      CaInfosRestResponse result = apiInstance.listCas();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling V1CaApi#listCas");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

This endpoint does not need any parameter.

Return type

CaInfosRestResponse

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 successful operation -

status1

RestResourceStatusRestResponse status1()

Get the status of this REST Resource

Returns status, API version and EJBCA version.

Example

// Import classes:
import com.keyfactor.ejbca.client.ApiClient;
import com.keyfactor.ejbca.client.ApiException;
import com.keyfactor.ejbca.client.Configuration;
import com.keyfactor.ejbca.client.model.*;
import com.keyfactor.ejbca.client.api.V1CaApi;

import java.nio.file.Path;

public class Example {
  public static void main(String[] args) {
    // Set base path to EJBCA REST API
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost/ejbca/ejbca-rest-api");

    // Retrieve client certificate and key
    Path cert = Paths.get("path/to/clientcertificate");
    Path key = Paths.get("path/to/key");
    defaultClient.setClientCert(cert, key);

    V1CaApi apiInstance = new V1CaApi(defaultClient);
    try {
      RestResourceStatusRestResponse result = apiInstance.status1();
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling V1CaApi#status1");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

This endpoint does not need any parameter.

Return type

RestResourceStatusRestResponse

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 successful operation -