Skip to content

Keyfactor/ejbca-go-client-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for ejbca

API reference documentation.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import ejbca "github.com/Keyfactor/ejbca-go-client-sdk/ejbca"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http:https://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), ejbca.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), ejbca.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), ejbca.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), ejbca.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

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

Class Method HTTP request Description
V1CaApi CreateCrl Post /v1/ca/{issuer_dn}/createcrl Create CRL(main, partition and delta) issued by this CA
V1CaApi GetCertificateAsPem Get /v1/ca/{subject_dn}/certificate/download Get PEM file with the active CA certificate chain
V1CaApi GetLatestCrl Get /v1/ca/{issuer_dn}/getLatestCrl Returns the latest CRL issued by this CA
V1CaApi ImportCrl Post /v1/ca/{issuer_dn}/importcrl Import a certificate revocation list (CRL) for a CA
V1CaApi ListCas Get /v1/ca Returns the Response containing the list of CAs with general information per CA as Json
V1CaApi Status1 Get /v1/ca/status Get the status of this REST Resource
V1CaManagementApi Activate Put /v1/ca_management/{ca_name}/activate Activate a CA
V1CaManagementApi Deactivate Put /v1/ca_management/{ca_name}/deactivate Deactivate a CA
V1CaManagementApi Status Get /v1/ca_management/status Get the status of this REST Resource
V1CertificateApi CertificateRequest Post /v1/certificate/certificaterequest Enrollment with client generated keys for an existing End Entity
V1CertificateApi EnrollKeystore Post /v1/certificate/enrollkeystore Keystore enrollment
V1CertificateApi EnrollPkcs10Certificate Post /v1/certificate/pkcs10enroll Enrollment with client generated keys, using CSR subject
V1CertificateApi FinalizeEnrollment Post /v1/certificate/{request_id}/finalize Finalize enrollment
V1CertificateApi GetCertificatesAboutToExpire Get /v1/certificate/expire Get a list of certificates that are about to expire
V1CertificateApi RevocationStatus Get /v1/certificate/{issuer_dn}/{certificate_serial_number}/revocationstatus Checks revocation status of the specified certificate
V1CertificateApi RevokeCertificate Put /v1/certificate/{issuer_dn}/{certificate_serial_number}/revoke Revokes the specified certificate
V1CertificateApi SearchCertificates Post /v1/certificate/search Searches for certificates confirming given criteria.
V1CertificateApi Status2 Get /v1/certificate/status Get the status of this REST Resource
V1ConfigdumpApi GetJsonConfigdump Get /v1/configdump Get the configuration in JSON.
V1ConfigdumpApi GetJsonConfigdumpForType Get /v1/configdump/{type} Get the configuration for type in JSON.
V1ConfigdumpApi GetJsonConfigdumpForTypeAndSetting Get /v1/configdump/{type}/{setting} Get the configuration for a type and setting in JSON.
V1ConfigdumpApi GetZipExport Get /v1/configdump/configdump.zip Get the configuration as a ZIP file.
V1ConfigdumpApi PostJsonImport Post /v1/configdump Put the configuration in JSON.
V1ConfigdumpApi PostZipImport Post /v1/configdump/configdump.zip Put the configuration as a ZIP file.
V1ConfigdumpApi Status4 Get /v1/configdump/status Get the status of this REST Resource
V1CryptotokenApi Activate1 Put /v1/cryptotoken/{cryptotoken_name}/activate Activate a Crypto Token
V1CryptotokenApi Deactivate1 Put /v1/cryptotoken/{cryptotoken_name}/deactivate Deactivate a Crypto Token
V1CryptotokenApi GenerateKeys Post /v1/cryptotoken/{cryptotoken_name}/generatekeys Generate keys
V1CryptotokenApi RemoveKeys Post /v1/cryptotoken/{cryptotoken_name}/{key_pair_alias}/removekeys Remove keys
V1CryptotokenApi Status5 Get /v1/cryptotoken/status Get the status of this REST Resource
V1EndentityApi Add Post /v1/endentity Add new end entity, if it does not exist
V1EndentityApi Delete Delete /v1/endentity/{endentity_name} Deletes end entity
V1EndentityApi Revoke Put /v1/endentity/{endentity_name}/revoke Revokes all end entity certificates
V1EndentityApi Search Post /v1/endentity/search Searches for end entity confirming given criteria.
V1EndentityApi Setstatus Post /v1/endentity/{endentity_name}/setstatus Edits end entity setting new status
V1EndentityApi Status6 Get /v1/endentity/status Get the status of this REST Resource
V1SshApi Pubkey Get /v1/ssh/{ca_name}/pubkey Retrieves a CA's public key in SSH format.
V1SshApi Status8 Get /v1/ssh/status Get the status of this REST Resource
V2CertificateApi GetCertificateProfileInfo Get /v2/certificate/profile/{profile_name} Get Certificate Profile Info.
V2CertificateApi SearchCertificates1 Post /v2/certificate/search Searches for certificates confirming given criteria and pagination.
V2CertificateApi Status3 Get /v2/certificate/status Get the status of this REST Resource
V2EndentityApi GetAuthorizedEndEntityProfiles Get /v2/endentity/profiles/authorized List of authorized end entity profiles for the current admin.
V2EndentityApi Profile Get /v2/endentity/profile/{endentity_profile_name} Get End Entity Profile content
V2EndentityApi SortedSearch Post /v2/endentity/search Searches and sorts for end entity conforming given criteria.
V2EndentityApi Status7 Get /v2/endentity/status Get the status of this REST Resource

Documentation For Models

Documentation For Authorization

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author