Pular para o conteúdo principal

GeCert API

The GeCert REST API is the one the web application and Gecert Connect use. The full description of the routes and models is in your instance's Swagger, at https://your-gecert-address/swagger.

Authentication​

Requests carry the Authorization: Bearer YOUR_TOKEN header, with an access token issued by the instance's GrantID for the GeCert API (the server's Oidc:ApiName setting). It is the same token the web application obtains when the user signs in and that Gecert Connect obtains at login. The organization-area routes operate on the organization the user belongs to, as the web application does.

Only the application configuration routes are anonymous:

RouteResponse
GET /api/app-configuration{"hidePoweredBy": false}
GET /api/app-configuration/gecert-connectThe minimum Gecert Connect version and whether the server is under maintenance: {"minSupportedVersion": "1.1.0.0", "underMaintenance": false}
GET /api/app-configuration/gecert-connect/serverThe server address and the GrantID data for Gecert Connect: serverUrl, grantIdAuthority, grantIdClientAppId, grantIdApiName, grantIdRedirectUri. Error GecertConnectServerNotConfigured if the GecertConnect section is not filled in
GET /api/system/infoThe product name and version: {"productName":"Gecert","productVersion":"1.x.x"}

Routes​

The lists (.../list) are paginated and accept the q (search), offset, limit and order parameters. The permission of each route is checked on the resource's organization; in the Sys Admin area, on the root.

Keys​

RouteWhat it doesPermission
GET /api/keys/listLists the organization's keysViewKeys
GET /api/keys/available/listLists the keys that have no certificate yetViewKeys
GET /api/keys/{id}/summaryKey summary: name, organization, certificate and key store typeViewKeys
GET /api/keys/{id}/detailsDetails: type, size and key store type. Answers with the CannotRetrieveKeyFromKeyStore failure when the key is not found in the key storeViewKeys
GET /api/keys/{id}/csrThe CSR kept for the key, in PEM, with the subject name and the hash algorithmViewKeys
POST /api/keys/{id}/custom-csrIssues a new CSR for the key. Body: {"params": "CN=...,O=...", "hashAlgorithm": "SHA256"}ManageKeys
GET /api/keys/{id}/parametersThe key's parameters in the key store, as JSON. Error KeyStoreParametersNotAccessible if the store does not allow key registrationViewKeys
GET /api/keys/{id}/parameters/accessibleWhether the parameters can be read (true or false)ViewKeys
GET /api/keys/{id}/eventsThe key's events, paginatedViewKeys
PUT /api/keysRegisters a key that already exists in the key store. Body: {"parameters": {"keyStore": "...", "keyName": "...", "keyStoreParameters": {...}}} (see below)ManageKeys
PUT /api/keys/{id}Renames the key. Body: {"name": "..."}ManageKeys
DELETE /api/keys/{id}Deletes the key (and removes it from the key store when hard deletion is configured). Error GecertKeyHasActiveCertificate if it has a certificateManageKeys

Certificates​

RouteWhat it doesPermission
GET /api/certificates/listLists the organization's certificates, with the number of authorized usersViewCertificates
GET /api/certificates/{id}Details: subject, issuer, type, e-mail, validity, SHA-1 thumbprint and the key IDViewCertificates
GET /api/certificates/{id}/eventsThe certificate's events, paginatedViewCertificates
GET /api/certificates/{id}/usageThe key usages of the certificate, paginatedViewCertificates
GET /api/certificates/{id}/authorized-usersThe users with access to the certificate, paginatedViewCertificateAccess
GET /api/certificates/{id}/public-bytesThe encoded certificate (DER), in Base64Certificate access (UseKey)
GET /api/certificates/myThe certificates the authenticated user has access toAuthenticated user
POST /api/certificatesAdds a certificate from a PKCS #12 uploaded beforehand. Body: {"blobId": "...", "keyStoreName": "...", "password": "..."}. Failures: CertificatePasswordIsIncorrect, CertificateAlreadyExistsOnSubscription, CertificateIsExpectedToHaveRsaKeysManageCertificates
PUT /api/certificatesRegisters a certificate (.cer) for an existing key. Body: {"blobId": "...", "keyId": "..."}. Failures: CertificateIsNotExpectedToHavePassword, CertificateAlreadyExistsOnSubscription, KeysAreNotEquivalentManageCertificates
DELETE /api/certificates/{id}Deletes the certificate, its accesses and its keyManageCertificates

The responses of POST and PUT /api/certificates have the format {"success": true, "id": "..."} or {"success": false, "failure": "CertificatePasswordIsIncorrect", "failureType": "NewCertificateResponseFailures"}.

Certificate accesses​

RouteWhat it doesPermission
GET /api/certificate-accessLists the organization's accesses, paginatedViewCertificateAccess
POST /api/certificate-accessGrants access. Body: {"certificateId": "...", "userId": "..."}. Failures: CertificateAccessAlreadyExists, UserNeedsSubscriptionAccess, UserHasAccessToThisCertificateInAnotherSubscriptionManageCertificateAccess
DELETE /api/certificate-access/{id}Removes one accessManageCertificateAccess
DELETE /api/certificate-access/certificates/{certificateId}Removes every access to a certificateManageCertificateAccess
DELETE /api/certificate-access/users/{userId}Removes every access of a user in the organizationManageCertificateAccess
POST /api/certificate-access/certificates/{from}/to/{to}Copies every access from one certificate to another. The response lists the result for each userManageCertificateAccess on both certificates
GET /api/users/{userId}/authorized-certificatesThe certificates a user has access toViewCertificateAccess
GET /api/users/{userId}/subscription-access/verificationWhether the user has access to the organization (true or false)ViewCertificateAccess

Key stores​

RouteWhat it doesPermission
GET /api/key-storesThe key stores the organization has access to: name, type, whether it is the default, whether it accepts key registration and insertion, hard delete, key sizes and name patternManageKeys
GET /api/key-stores/{type}/exampleAn example of the registration parameters for the type (Kryptus, AzureKeyVault or Pkcs11)ManageKeys
GET /api/key-stores/listEvery key store configured in the instance, paginatedRead on the root (Sys Admin)
GET /api/key-stores/details?name=...The details of a key store, by type: for Azure Key Vault, the endpoint, the application ID and whether it uses HSM; for Kryptus, the host, port and users; for PKCS #11, the module and the token serial numberRead on the root (Sys Admin)
GET /api/subscriptions/my/key-storesThe organization's key store accessesManageKeys
GET /api/subscriptions/{id}/key-storesThe key store accesses of an organization, paginatedViewKeyStoreAccess on the root
POST /api/key-store-accessGrants an organization access to a key store. Body: {"subscriptionId": "...", "keyStoreName": "..."}. Failure: KeyStoreAccessAlreadyExistsManageKeyStoreAccess on the root
DELETE /api/key-store-access/{id}Removes the access. The keys already on the key store continue to workManageKeyStoreAccess on the root

Key usages​

RouteWhat it doesPermission
GET /api/key-usages/listThe usages of the organization's keys, paginated: date, certificate, user, operation (Encrypt, Decrypt, Sign or Verify), algorithm, hash, value and, for verifications, whether the signature was validViewCertificates

Reports​

RouteWhat it doesPermission
POST /api/reports/certificates/expiration-dateGenerates the expiration report of the organization's certificates (name, e-mail and expiration date). Body: {"fileType": "Xlsx"}, "Csv" or "Pdf"ManageCertificates
POST /api/reports/certificates/{id}/eventsGenerates the report of the events of one certificate (date, entity, operation, details, agent and organization)ManageCertificates
GET /api/reports/{id}?fileType=...Downloads the generated reportAccess ticket returned by the generation

The generation answers with {"success": true, "ticket": {"location": "..."}}, where location is the address to download the file; or with the EmptyReport failure, when there is nothing to include.

API used by Gecert Connect​

These routes, also under /api/keys, are the ones Gecert Connect calls on behalf of the Lacuna Key Storage Provider. They only see the keys of the certificates the authenticated user has access to, and every operation with the private key requires the UseKey permission and is recorded in the key usages.

RouteWhat it does
GET /api/keysThe user's keys: [{"id": "...", "attributes": {"enabled": true}}]
GET /api/keys/{id}The public key: {"id": "...", "keyType": "RSA", "keyOperations": ["Encrypt", "Decrypt", "Sign", "Verify", "WrapKey", "UnwrapKey"], "rsaModulus": "...", "rsaPublicExponent": "...", "managed": true}, with the modulus and exponent in Base64
POST /api/keysCreates an RSA key in the current organization. Body: {"keyName": "...", "keyStore": "...", "keySize": 2048, "keyType": "RSA"}. Requires ManageKeys
POST /api/keys/{id}/signatureSigns a hash. Body: {"algorithm": "RS256", "value": "HASH_IN_BASE64"}; algorithm can be RS256 (default) or RS512. Response: the signature, in Base64
POST /api/keys/{id}/decryptionDecrypts. Body: {"algorithm": "RSA1_5", "value": "DATA_IN_BASE64"}; RSA1_5 (PKCS #1 v1.5) is the only padding and the default. Response: the decrypted data, in Base64
POST /api/keys/{id}/encryptionEncrypts with the certificate's public key. Same body and response
POST /api/keys/{id}/signature-verificationVerifies a signature with the public key. Body: {"algorithm": "RS256", "value": "SIGNATURE_IN_BASE64", "digest": "HASH_IN_BASE64"}. Response: true or false
GET /api/keys/stopwatch-info, GET /api/keys/{id}/stopwatch-infoThe same responses as GET /api/keys and GET /api/keys/{id}, with the time spent in each step (database, key store connection, reading the parameters), used by Check server connection

An algorithm other than the accepted ones answers with the OperationAlgorithmNotSupported error.

Key registration parameters​

To register a key that already exists in the key store (PUT /api/keys or Register existing key), give the parameters that identify it, according to the key store type. The type field is required, and GET /api/key-stores/{type}/example returns a template. GeCert tests the parameters before saving: it reads the public key and signs a CSR with the key; if that fails, it answers with KeyStoreParametersFailedValidation.

Key storeParameters
Kryptus HSM{"type": "Kryptus", "publicKeyUniqueIdentifier": "...", "privateKeyUniqueIdentifier": "..."}: the KMIP unique identifiers of the public and private keys
Azure Key Vault{"type": "AzureKeyVault", "keyName": "..."} or {"type": "AzureKeyVault", "kid": "https://.../keys/name/version"}, with the optional kty (RSA, RSA-HSM, EC or EC-HSM) and curveName
PKCS #11 device{"type": "Pkcs11", "id": "...", "label": "..."}: the key's ID (in Base64; in the web application, also in hexadecimal) or its label. At least one of the two

The database key store does not accept key registration, and any key store can have registration disabled in the configuration (KeyRegistrationDisabled): the error is then KeyStoreDoesNotSupportKeyRegistration.

Error codes​

Errors have the format {"code": "...", "message": "..."}, with the matching HTTP status code. Besides the platform's common codes (SubscriptionNotFound, UserNotFound, UploadNotFound, RoleMissing and others), GeCert defines:

CodeWhen it happens
CertificateNotFound, GecertKeyNotFound, CertificateAccessNotFound, KeyStoreAccessNotFoundThe resource does not exist or does not belong to the organization
SubscriptionMismatchThe given key belongs to another organization
BadKeyStoreThe given key store is not configured in the instance
BadKeyStoreParametersThe registration parameters could not be read
KeyStoreParametersFailedValidationThe key could not be used with the given parameters
KeyParametersIncompatibleWithCertificateThe key does not match the certificate
KeyStoreDoesNotSupportKeyRegistrationThe key store does not accept registration of existing keys
KeyStoreDoesNotSupportKeyInsertionThe key store does not accept key generation or import (KeyInsertionDisabled)
KeyStoreParametersNotAccessibleThe key parameters cannot be shown for this key store
PinProtectionNotSupportedThe key store does not support partitions
GecertKeyHasActiveCertificateThe key cannot be deleted because it has a certificate
OperationAlgorithmNotSupportedThe operation algorithm is not RS256, RS512 or RSA1_5
GecertConnectServerNotConfiguredThe server's GecertConnect section is not filled in

See also​

View as Markdown