how to get a free ssl certificate code example

Example 1: how to get free ssl certificate from letsencrypt for local

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Example 2: what is an SSL certificate

An SSL certificate is a type of digital certificate that 
provides authentication for a website and enables an encrypted connection. 
communicates to the client that the web service host 
demonstrated ownership of the domain to the certificate authority 
at the time of certificate issuance