REST API  16
REST API for Luna Network HSMs
POST /api/lunasa/webServer/csr

POST /api/lunasa/webServer/csr

Generates a certificate signing request for the webserver's certificate.

User Privileges

Users with the following role privileges can perform this command:

  • admin
  • operator

Parameters

curveName

curveName is the elliptic curve used for an ECDSA-based certificate that will be configured as part of the certificate signing request.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 1
   maxLength: 64
   pattern: ^[a-zA-Z0-9]{1,64}$

keyType

keyType is the type of key that will be configured as part of the certificate signing request.

Use: Required

JSON Schema:

   Object
   type: string
   minLength: 3
   maxLength: 3
   pattern: ^(rsa|ecc)$

keySize

keySize is the number of bits for the key that will be configured as part of the certificate signing request.

Use: Required

JSON Schema:

   Object
   type: integer

cn

cn is the common name that will be configured as part of the certificate signing request.

Use: Required

JSON Schema:

   Object
   type: string
   minLength: 1
   maxLength: 64
   pattern: ^[a-zA-Z0-9 '()+,.\/:=?-]*$

country

country is the country that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 2
   maxLength: 2
   pattern: ^(A-Z){2}

state

state is the state that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 1
   maxLength: 64
   pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,63}$

location

location is the location that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 1
   maxLength: 64
   pattern: ^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$

organization

organization is the organization that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 1
   maxLength: 64
   pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,63}$

orgunit

orgunit is the organization unit that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 1
   maxLength: 64
   pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,63}$

email

email is the email that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: string
   minLength: 3
   maxLength: 128
   Pattern: ^(\w+)(\.|_)?(\w*)@(\w+)(\.(\w+))+$

subjectAltNames

subjectAltName is the array of alternate names that will be configured as part of the certificate signing request's subject.

Use: Not Required

JSON Schema:

   Object
   type: array
      subjectAltName: Obect
      type: string
      minLength: 1
      maxLength: 64
      pattern: ^([a-zA-Z0-9_.-]{0,63}){1,10}(,[a-zA-Z0-9_.-]{0,63}){0,10}$

startDate

startDate is the starting date that will be configured as part of the certificate signing request.

Use: Not Required

JSON Schema:

   Object
   type: string
   pattern: ^\d{4}-[0-1]{1}\d{1}-[0-3]{1}\d{1}$

days

days is the duration that will be configured as part of the certificate signing request.

Use: Not Required

JSON Schema:

   Object
   type: integer
   minValue: 1
   maxValue: 3653

Responses

200

Data buffer containing the file contents.

400

FRAMEWORK_BAD_REQUEST

We failed to parse your request.

Example Request

   POST
   https://1.2.3.4:8443/api/lunasa/webServer/csr

   {
   "keyType" : "rsa",
   "keySize" : 2048,
   "subjectAltNames" : ["example.com", "www.example.com"],
   "cn" : "1.2.3.4",
   "startDate" : "2020-11-20",
   "days" : 365
   }

Example Result

{
  
}

Notes

This resource returns the contents of a file in a buffer.

Below is an example of getting the contents in python. We iterate through the contents and save them to a file.

        r = requests.post("/api/lunasa/webServer/csr",
                         stream=True,
                         cookies=cookies,
                         verify=False,
                         allow_redirects=False,
                         data=payload)

        with open("ssl.csr", 'wb') as csr:
          for chunk in r.iter_content(chunk_size=1024):
              if chunk:
                  csr.write(chunk)
          csr.close()