Code Monkey home page Code Monkey logo

self-signed-ssl's Introduction

ANNOUNCEMENT

I have released another PKI utility named acert.
It is a Golang project and independent of OpenSSL.
Options, options... ๐Ÿค”


Self Signed SSL

This script simplifies the creation of certificate authorities, signing requests and self-signed TLS certificates using OpenSSL.

Video Tutorial

Self-Signed SSL - Introduction Video


Installation


Homebrew (MacOS)

brew tap lstellway/formulae
brew install lstellway/formulae/self-signed-ssl

cURL

curl --output self-signed-ssl https://raw.githubusercontent.com/lstellway/self-signed-ssl/master/self-signed-ssl && chmod +x self-signed-ssl

Usage

self-signed-ssl [OPTIONS]

# Run with no arguments to be prompted for required values
self-signed-ssl

# Only create a certificate authority and trust the generated certificate
self-signed-ssl --ca-only --trust

# Only create a certificate signing request
self-signed-ssl --csr-only

# Generate a signed certificate using existing files
self-signed-ssl --ca='/path/to/CA.pem' --ca-key='/path/to/CA.key' --csr='/path/to/EXAMPLE.csr'

# Automate certificate generation
self-signed-ssl --no-interaction -c 'US' -s 'California' -l 'Los Angeles' -o 'Example Org' -u 'Example Unit' -n 'example.com' -a 'www.example.com'

Options


General

Option Description
-h --help Display help and exit
-v --version Display the script version and exit
-p VALUE --path=VALUE Path to output generated keys
-d VALUE --duration=VALUE Number of days the certificate is valid (default 365)
-b VALUE --bits=VALUE Key size in bits (default 2048)
--no-interaction Disables interactive prompts for unspecified variables.
(OpenSSL may still prompt for values)

Certificate Authority

Option Description
--ca=VALUE Path to certificate authority cert file
(Generates new CA if not set)
--ca-key=VALUE Path to certificate authority key file
(Generates new CA if not set)
--ca-only Instructs script to solely generate a certificate authority
--ca-ext Allow passing extensions to the CA request
-t --trust Flag to trust certificate authority (requires sudo privileges)
(Currently supports Darwin/MacOS, Fedora/CentOS, Debian/Ubuntu)

Certificate Signing Request

Option Description
--csr Path to certificate signing request
(Generates new certificate signing request if not set)
--csr-only Instructs script to solely generate a certificate signing request

Certificate / Subject

Option Description
--extfile=VALUE Path to file containing OpenSSL certificate extensions
(Optional - generated if not provided)
-c VALUE --country=VALUE Country Name (2 letter code)
-s VALUE --state=VALUE State or Province Name (full name)
-l VALUE --locality=VALUE Locality Name (eg, city)
-o VALUE --organization=VALUE Organization Name (eg, company)
-u VALUE --unit=VALUE Organizational Unit Name (eg, section)
-n VALUE --common-name=VALUE Common Name (e.g. server FQDN or YOUR name)
-a VALUE --san=VALUE Comma-delimited list of subject alternative names (Subdomains, etc..)
-e VALUE --email=VALUE Email Address

Resources

self-signed-ssl's People

Contributors

fearlesshyena avatar idangozlan avatar lstellway avatar mercutiodesign avatar slw07g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

self-signed-ssl's Issues

Warning: Not generating key via given -newkey option since -key is given

+ CSR=/Users/kes/dev/wi-deploy/docker-images/base/prd.ca.csr
+ openssl genrsa -out /Users/kes/dev/wi-deploy/docker-images/base/prd.ca.key 2048
+ openssl req -new -nodes -sha256 -subj /CN=prd.ca -newkey rsa:2048 -key /Users/kes/dev/wi-deploy/docker-images/base/prd.ca.key -out /Users/kes/dev/wi-deploy/docker-images/base/prd.ca.csr
Warning: Not generating key via given -newkey option since -key is given

TODO: We can remove newkey option.

--san parameter is mandatory ?

Hello,

The --san parameter is currently mandatory and makes a prompt if not defined. It should not as this is parameter is optional (it currently fails our automatic scripts).

Thank you !

IP cert

its working fine when i put localhost.
but when i try the iP. it does not work

my input as per below
./gen.sh -c=ID -s=KP -l=kuta -o=onecom -u=mobotix -n=192.168.0.123 -e=[email protected]

Linux OSTYPE support while trusting certificate

Hi, this is not an issue per se, however I figured I'd let you know (plus might be useful to any Google lurkers around here). I downloaded your script to test it on a Debian Buster at work, and while running :
./self-signed-ssl --ca-only --trust
I got the following output :

Country Name (2 letter code) [AU]: XX
State or Province Name (full name) [Some-State]: XX
Locality Name (eg, city) []: XX
Organization Name (eg, company) [Internet Widgits Pty Ltd]: XX
Organizational Unit Name (eg, section) []: XX
Common Name (e.g. server FQDN or YOUR name) []: local-ca
Subject Alternative Name(s) (e.g. subdomains) []:
Email Address []:
Building certificate authority
Generating RSA private key, 2048 bit long modulus (2 primes)
...................................+++++
........+++++
e is 65537 (0x010001)

Error occurred while trusting certificate for OSTYPE 'linux-gnu'
Please ensure you are on a supported system and have the required packages installed.

Indeed, if I echo $OSTYPE, my result is not "linux", but "linux-gnu", which is not recognized by the script. So I had to edit the script to allow linux and linux-gnu in OSTYPEs in the "Trust certificate authority" part of your script ! =)

Thanks a lots for your work though, really impressive !

Syntax error

Throws an error on Centos7 / standard bash:

createcert.sh: line 193: syntax error near unexpected token `('
createcert.sh: line 193: `  openssl req -new -sha256 -nodes -out "${OUTPATH}${FILENAME}.csr" -newkey rsa:2048 -keyout "${OUTPATH}${FILENAME}.key" -config <( cat "${tmp}/tmp.csr.cnf" )'

Support for IP addresses in 'Subject Alternative Names?'

The script works great as-is, however, when creating the certs, the script only asks for (sub)domains not for an IP address. As such, when I try to access HTTPS IP address URL, I get expected 'NET::ERR_CERT_COMMON_NAME_INVALID' HTTPS error.

Although I'm not a programmer, I read that the script only has SAN="${SAN}DNS.${i} = ${u// /}"$'\n' not something like SAN="${SAN}IP.${i}...

If you wouldn't mind, would you be able to add support for IP address in Subject Alternative Names, thanks.

problems making Certificate Request

I we got error while creating certificate:

OS: ARMBIAN 5.36 user-built Ubuntu 16.04.3 LTS 3.4.113-sun8i
OpenSSL: OpenSSL 1.0.2g  1 Mar 2016
#uname -a
Linux orangepizero 3.4.113-sun8i #4 SMP PREEMPT Wed Nov 22 13:45:28 CET 2017 armv7l armv7l armv7l GNU/Linux

Log:

Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:orange.vpn
Email Address []:
Generating RSA private key, 2048 bit long modulus
..............+++
.........................................................+++
e is 65537 (0x10001)
end of string encountered while processing type of subject name element #6
problems making Certificate Request
Generating a 2048 bit RSA private key
.................................+++
.....................+++
writing new private key to './orange.vpn.key'
-----
problems making Certificate Request
3070130000:error:0D07A098:asn1 encoding routines:ASN1_mbstring_ncopy:string too short:a_mbstr.c:151:minsize=2
./orange.vpn.csr: No such file or directory

Rework API to use subcommands

Many other CLI utilities seem to be moving towards using a subcommand structure.
It could be nice to break things up using the following subcommands:

  • ca
  • csr
  • cert|certificate

Add --csr argument

Add an argument to allow users to provide their own CSR used to sign a certificate.

Arguments Ignored

I tried passing in the -c and --country options and they were both ignored.

How to use

I clone this and run bach file as ssl.bat but nothing happen.
May you help me how to use this?

Script name / disparity

Description

Currently, the repository name is self-signed-ssl
The actual script is named self-signed-tls

This may be confusing for people.

The script is a wrapper around OpenSSL.
Perhaps a name pertaining to that software would make sense.

Keeping it generic using -ssl would work for another idea I had:
To be able to use the script to generate boringssl certificates.

  • I have not yet looked at the boringssl API.
    • Google says it often changes - probably a bit beyond the scope of what this script should do.

Possible solutions:

  • Create an alias in the Homebrew installation.
    • This will maintain backwards compatibility for anyone using self-signed-tls

V3 Certificate Authority

I noticed while trying to use the script to generate a CA for cert-manager that the generated CA was not being recognized as an authority.

Here is a related answer to the issue which recommends appending the following to /etc/ssl/openssl.cnf:

[ v3_ca ]
basicConstraints = critical,CA:TRUE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer:always

And specifying -extension v3_ca in the openssl req command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.