Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Create FreeSSL Certificate Using Rest Api

This Rest Api tutorial help to create SSL certificate using zerossl API.The SSL certificates are used to create an encrypted channel between the client and the server.

I am using ZeroSSL to create SSL Certificate.The ZeroSSL makes it easy to create, install and manage SSL certificates of any kind by offering an easy-to-use user interface.I am using Rest API to create Certificate but you can create using UI by following How To Generate SSL Certificate Using ZeroSSL UI tutorial.

How To Generate SSL Certificate By Using API

The ZeroSSL offering a full-fledged SSL REST API that will allow you to automate all of the actions from UI supports and perform them using a secure, fast and straightforward API interface.

We ll follow below steps to generate a free SSL Certificate –

  • Create Certificate
  • Verify Domain Ownership
  • Download Certificate

We will use above three rest api to generate ssl certificates.

Base URL

You need to use a simple API base URL, variable endpoints and requests using HTTP GET and POST.
api.zerossl.com

How To Get and Pass API Access Key

They are providing access_key to access rest api. Each user account is assigned a unique API access key, which must be passed to the API using a simple HTTP GET request parameter called access_key. You will find your API access key in the Developer section of your ZeroSSL management console.

api.zerossl.com/endpoint?access_key=EXAMPLE_KEY

How To Create SSL Certificates

We ll use /certificate method to generate SSL certificate, Let’s create python API and defined to generate certificate –

@app.route('/certificates', methods=['POST'])
def create():
    """ data = {'certificate_domains': 'restapiexample.com',
      'certificate_validity_days': 90}"""
    r = requests.post('https://api.zerossl.com/certificates?access_key=access_key', json = request.data)

    return r.json()

Above call will return response that ll have certificate details.We ll use id for further api call.

How To Verify Domain

Once Your SSL certificate to be issues.You need to verify ownership of all domains included in your certificate. There are four methods that can be used to verify domains: email verification, verification via DNS (CNAME), verification via HTTP file upload and verification via HTTPS file upload.

api.zerossl.com/certificates/{id}/challenges

I am using email type verification method to validate ownership, So I ll pass emailId into post payloads –

@app.route('/verify_domains/{id}/', methods=['POST'])
def create():
    """ {'validation_method': 'Email',
      'validation_email': '[email protected]'}"""
    r = requests.post('https://api.zerossl.com/certificates/{id}/challenges?access_key=access_key', json = request.data)

    return r.json()

{id} – The {id} must be replaced with your certificate ID (hash).

Once the API request was successful, You will receive a verification email to the selected verification email address for each of the domains in your certificate.

API To Download Certificate (ZIP)

You can download certificate as a ZIP-file using /download end point.

api.zerossl.com/certificates/{id}/download

@app.route(‘/download/{id}’, methods=[‘GET’])
def download_zip():
r = requests.get(‘https://api.zerossl.com/certificates/{id}/download’) return r.json()

You will receive a ZIP file containing the following items:

  • certificate.crt: This file contains your primary SSL certificate, ready to be installed on your server.
  • ca_bundle.crt: This file contains a chain of root and intermediate certificates, which need to be installed on your server along with the .crt file in order for your certificate to work.
  • private.key: This file contains your private key, which will need to be uploaded to your server as well.

Hurrey, We have created and downloaded ssl certificates, Now You can install it on you website using webhosting cpanel. Each web-hosting provider define the steps to install ssl into domain.You just need to follow that steps o install ssl certificate.

The post How To Create FreeSSL Certificate Using Rest Api appeared first on Rest Api Example.



This post first appeared on Rest Api Example, please read the originial post: here

Share the post

How To Create FreeSSL Certificate Using Rest Api

×

Subscribe to Rest Api Example

Get updates delivered right to your inbox!

Thank you for your subscription

×