Giter Club home page Giter Club logo

pric / pric Goto Github PK

View Code? Open in Web Editor NEW
114.0 7.0 12.0 40 KB

Simple zero-config tool to create Private Certificate Authority & issue locally-trusted development server certificates with any domain names you'd like. SSL certificates for development purposes.

Home Page: https://komarev.com/sources/pric

License: MIT License

Shell 100.00%
ssl ssl-certificate developer-tools development webserver openssl openssl-certs localhost console-application terminal-app

pric's People

Contributors

antonkomarev 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

pric's Issues

Linux distributive Solus not supported

sh pric.sh
!pric has been started

# Creating output directory
+ mkdir -p ./output

# Copying OpenSSL base config from defaults
+ cp ./openssl.base.default.cnf ./openssl.base.cnf

# Copying OpenSSL DNS config list from defaults
+ cp ./openssl.dns.default.cnf ./openssl.dns.cnf

# Compiling OpenSSL final config from intermediates
+ cat ./openssl.base.cnf ./openssl.dns.cnf > "./output/openssl.cnf"

# Creating !pric directory in operating system CA registry
+ sudo mkdir -p '/usr/local/share/ca-certificates/!pric'
Password: 

# Generating Certificate Authority private key
+ openssl genrsa -out ./output/ca.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
............................+++++
...............................+++++
e is 65537 (0x010001)

# Copying Certificate Authority private key to operating system CA registry
+ sudo cp ./output/ca.key '/usr/local/share/ca-certificates/!pric/ca.key'

# Generating Certificate Authority self-signed certificate
+ openssl req -x509 -new -nodes -key ./output/ca.key -sha256 -days 825 -subj '/O=\!pric/CN=localhost' -out ./output/ca.crt

# Copying Certificate Authority certificate to operating system CA registry
+ sudo cp ./output/ca.crt '/usr/local/share/ca-certificates/!pric/ca.crt'

# Updating operating system CA registry

Unsupported Linux Distributive: Solus
Create an issue on GitHub https://github.com/pric/pric/issues/new?title=Linux+distributive+Solus+not+supported

[Concept] Interactive UI

Command sh pric.sh should open interactive UI with following items:

  • Domain Names sh pric.sh dn
  • Certificate Authority sh pric.sh ca
  • Server Certificate sh.pric.sh sc
  • Quick Start sh pric.sh qs

sh pric.sh dn

Tool to change domains list. It opens interactive UI with following items:

  • List domains sh pric.sh dn --list - display domains list
  • Add domain sh pric.sh dn --add="*.test.localhost" - add domain to the list
  • Remove domain sh pric.sh dn --remove="*.test.localhost" - remove domain from the list
  • Replace domains sh pric.sh dn --replace="localhost,*.test.localhost" - replace all domains in the list

sh pric.sh qs

Qick Start (current behavior): create all directories, missing configs, generate CA, add CA to trusted, generate server certificate

Display executed command is broken on file concatenation

Command:

(set -x; cat ${OUTPUT_SERVER_CERTIFICATE} ${CA_CERTIFICATE} ${OUTPUT_SERVER_PRIVATE_KEY} > "${CERTIFICATE_CHAIN}")

Expected Output:

+ cat ./output/localhost.crt /usr/local/share/ca-certificates/!pric/ca.crt ./output/localhost.key > ~/localhost-certificate.pem

Actual Output:

+ cat ./output/localhost.crt /usr/local/share/ca-certificates/!pric/ca.crt ./output/localhost.key

CA OS directory naming

Rename /usr/local/share/ca-certificates/pric/ to /usr/local/share/ca-certificates/!pric/ to follow same naming convention. Then CA directory will be listed as first item and it's first character exclamation sign telling that it's something dangerous yet very important.

Add local dev dns config file

Need to add ability to add new domains to the DNS list dynamically.

  1. Rename dns.cnf to dns.default.cnf
  2. Add dns.cnf to .gitignore
  3. On sh pric.sh launch if there is no dns.cnf file exists - copy dns.default.cnf to it

Fix Mac OS OpenSSL include DNS config file

Follow up to #7

!pric throws error on include openssl.dns.cnf in openssl.cnf config file on Mac OS:

+ openssl req -new -key ./output/localhost.key -config ./openssl.cnf -subj '/O=\!pric/CN=localhost' -out ./output/localhost.csr

error on line 368 of ./openssl.cnf
4409359852:error:0EFFF065:configuration file routines:CRYPTO_internal:missing equal sign:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.11.1/libressl-2.8/crypto/conf/conf_def.c:344:line 368

.include openssl.dns.cnf

Overwriteable OpenSSL config file

openssl.cnf should be added to .gitignore file.
On pric run create openssl.cnf file from openssl.cnf.example if config is missing.

This gives developer ability to overwrite default openssl config file and it will be untouched.

Not working SSL

I have downloaded and compete all steps but it's not working on the localhost.
here is log

pric has been started

Creating output directory
+ mkdir -p ./output

Creating pric directory in Operating System CA registry
+ sudo mkdir -p /usr/local/share/ca-certificates/pric

Generating Certificate Authority private key
+ openssl genrsa -out ./output/ca.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
...........................+++++
.........................................+++++
e is 65537 (0x010001)

Copying Certificate Authority private key to Operating System CA registry
+ sudo cp ./output/ca.key /usr/local/share/ca-certificates/pric/ca.key

Generating Certificate Authority self-signed certificate
+ openssl req -x509 -new -nodes -key ./output/ca.key -sha256 -days 36500 -subj /O=\!pric/CN=localhost -out ./output/ca.crt

Copying Certificate Authority certificate to Operating System CA registry
+ sudo cp ./output/ca.crt /usr/local/share/ca-certificates/pric/ca.crt

Updating Operating System CA registry
+ sudo update-ca-certificates
Updating certificates in /etc/ssl/certs... WARNING: Skipping duplicate certificate UbuntuOne-Go_Daddy_Class_2_CA.pem
WARNING: Skipping duplicate certificate UbuntuOne-Go_Daddy_Class_2_CA.pem
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.

Generating localhost private key
+ openssl genrsa -out ./output/localhost.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
.................+++++
................................................+++++
e is 65537 (0x010001)

Generating localhost certificate signing request
+ openssl req -new -key ./output/localhost.key -config openssl.cnf -subj /O=\!pric/CN=localhost -out ./output/localhost.csr

Generating localhost certificate signed by Certificate Authority
+ openssl x509 -req -extensions v3_req -extfile openssl.cnf -in ./output/localhost.csr -CA /usr/local/share/ca-certificates/pric/ca.crt -CAkey ./output/ca.key -CAcreateserial -CAserial ./output/ca.srl -days 36500 -sha256 -out ./output/localhost.crt
Signature ok
subject=O = !pric, CN = localhost
Getting CA Private Key

Compiling PEM certificate chain
+ cat ./output/localhost.crt /usr/local/share/ca-certificates/pric/ca.crt ./output/localhost.key

Trust Certificate Authority in MacOS

Here is how we could add self-signed certificate to trusted on mac:

# Add certificate to the trusted root store
sudo security add-trusted-cert \
  -d -r trustRoot \
  -k /Library/Keychains/System.keychain ./output/ca.crt

Need to check if it's working.

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.