All Projects → Shyp → Generate Tls Cert

Shyp / Generate Tls Cert

Generating self signed certificates

Programming Languages

javascript
184084 projects - #8 most used programming language
go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Generate Tls Cert

Vim Http
simple vim plugin to make http requests from buffers
Stars: ✭ 90 (-33.33%)
Mutual labels:  curl
Mpdas
MPD AudioScrobbler written in C++ using libcurl
Stars: ✭ 101 (-25.19%)
Mutual labels:  curl
React Native Vdebug
React-Native 调试工具,支持Console终端、Network导出cURL,可视化Response,Retry cURL。
Stars: ✭ 124 (-8.15%)
Mutual labels:  curl
Curl2httpie
covert command arguments between cURL and HTTPie
Stars: ✭ 92 (-31.85%)
Mutual labels:  curl
Gql
Very simple CLI for many GraphQL schemas in the cloud. Provides autocompletion for GraphQL queries
Stars: ✭ 101 (-25.19%)
Mutual labels:  curl
H2c
headers 2 curl. Provided a set of HTTP request headers, output the curl command line for generating that set. Try the converter online at
Stars: ✭ 113 (-16.3%)
Mutual labels:  curl
Androidhttp
Android Http网络开发神兵利器
Stars: ✭ 88 (-34.81%)
Mutual labels:  curl
Curl
一个轻量级的 PHP 网络操作类, 基于 Curl 封装并实现了 Get | Post | Upload | Download 等常用方法。
Stars: ✭ 132 (-2.22%)
Mutual labels:  curl
Curl To Go
Convert curl commands to Go code in your browser
Stars: ✭ 1,372 (+916.3%)
Mutual labels:  curl
Twurl
OAuth-enabled curl for the Twitter API
Stars: ✭ 1,648 (+1120.74%)
Mutual labels:  curl
Getnews.tech
A web server that fetches data from the News API and formats it for display in the terminal.
Stars: ✭ 94 (-30.37%)
Mutual labels:  curl
Grawler
Grawler is a tool written in PHP which comes with a web interface that automates the task of using google dorks, scrapes the results, and stores them in a file.
Stars: ✭ 98 (-27.41%)
Mutual labels:  curl
Notebook
我的技术笔记本~
Stars: ✭ 118 (-12.59%)
Mutual labels:  curl
Katipo
HTTP2 client for Erlang based on libcurl and libevent
Stars: ✭ 90 (-33.33%)
Mutual labels:  curl
Ttfb.sh
Measures time-to-first-byte in seconds, for single or multiple URLs. Can calculate fastest, slowest & median TTFB values, and optionally log all response headers. Uses curl and the calculation `%{time_starttransfer} - %{time_appconnect}` which doesn't include any connection overhead, to better approximate devtool’s TTFB figure.
Stars: ✭ 123 (-8.89%)
Mutual labels:  curl
Curl Tap Sh
tap curl in your editor before it gets to sh it
Stars: ✭ 89 (-34.07%)
Mutual labels:  curl
Wuzz
Interactive cli tool for HTTP inspection
Stars: ✭ 9,845 (+7192.59%)
Mutual labels:  curl
Appleapnpush
Send push notification to Apple Devices (iPhone, iPad)
Stars: ✭ 134 (-0.74%)
Mutual labels:  curl
Curldrop
⏫ web app for for easy file uploads via curl
Stars: ✭ 125 (-7.41%)
Mutual labels:  curl
Walkman
Write HTTP requests in Org mode and replay them at will using cURL
Stars: ✭ 120 (-11.11%)
Mutual labels:  curl

Better self-signed certificates

Here's a script that helps you generate self signed certificates. It will generate both a root certificate and a leaf.

(The TLS certificates generated by crypto/tls/generate_cert.go act both as a CA and as a leaf certificate. Some TLS clients have a problem with that scheme.)

This script modifies crypto/tls/generate_cert.go slightly:

  • A leaf certificate and a root certificate are generated.

  • the only supported key type is ecdsa P256.

  • Better usage instructions are generated.

Credit comes from Adam Langley, who provided the initial version of this script on a golang-nuts message thread.

Installation

go get github.com/Shyp/generate-tls-cert

Usage

Running generate-tls-cert will give you nine files. Three of them are the most important:

  • root.pem: The public key of the root CA. Add this as a CA in clients to connect to your self-signed server (see "Client" below).

  • leaf.key and leaf.pem - The public and private key for terminating TLS with your self signed certificate.

$ generate-tls-cert --host=localhost,127.0.0.1
Successfully generated certificates! Here's what you generated.

# Root CA

root.key
	The private key for the root Certificate Authority. Keep this private.

root.pem
	The public key for the root Certificate Authority. Clients should load the
	certificate in this file to connect to the server.

root.debug.crt
	Debug information about the generated certificate.

# Leaf Certificate - Use these to serve TLS traffic.

leaf.key
	Private key (PEM-encoded) for terminating TLS traffic on the server.

leaf.pem
	Public key for terminating TLS traffic on the server.

leaf.debug.crt
	Debug information about the generated certificate

# Client Certificate - You probably don't need these.

client.key: Secret key for TLS client authentication
client.pem: Public key for TLS client authentication

Add the following instructions to your Makefile, and all your users will have to do to get started is run make generate_cert to download the binary and load TLS certificates.

GENERATE_TLS_CERT = $(GOPATH)/bin/generate-tls-cert

$(GENERATE_TLS_CERT):
	go get -u github.com/Shyp/generate-tls-cert

certs/leaf.pem: | $(GENERATE_TLS_CERT)
	mkdir -p certs
	cd certs && $(GENERATE_TLS_CERT) --host=localhost,127.0.0.1

# Generate TLS certificates for local development.
generate_cert: certs/leaf.pem | $(GENERATE_TLS_CERT)

Client Side

Here's how to make requests that validate, using your new TLS certificates.

Go

rootPEM, err := ioutil.ReadFile("path/to/root.pem")
if err != nil {
	log.Fatal(err)
}
roots := x509.NewCertPool()
ok := roots.AppendCertsFromPEM(rootPEM)
if !ok {
	panic("failed to parse root certificate")
}

// Use the tls.Config here in http.Transport.TLSClientConfig
conn, err := tls.Dial("tcp", "yourhost:yourport", &tls.Config{
    RootCAs: roots,
})
if err != nil {
    panic("failed to connect: " + err.Error())
}
conn.Close()

Javascript

var fs = require('fs');
var https = require('https');

var get = https.request({
  path: '/', hostname: 'yourhost', port: yourport,
  ca: fs.readFileSync('path/to/root.pem'),
  agent: false,
  rejectUnauthorized: true,
}, function(response) {
  response.on('data', (d) => {
    process.stdout.write(d);
  });
});

get.on('error', function(e) {
  console.error(e)
  console.error("error", e)
  console.error("error", JSON.stringify(e))
});

get.end();

Curl

curl --cacert path/to/root.pem https://yourhost:yourport

Python Requests

import requests

r = requests.get("https://yourhost:yourport", verify='root.pem')
print(r.status_code)

OpenSSL

openssl s_client -showcerts -servername localhost -CAfile path/to/root.pem -connect yourhost:yourport

Server Side

Here's how to integrate the generated certificates into different server architectures.

Go

Start the Go server with the leaf public and private keys.

http.ListenAndServeTLS(":7252", "leaf.pem", "leaf.key", nil)

Node.js

Start a Node server with the leaf public and private keys.

const https = require('https');
const fs = require('fs');

const options = {
  key: fs.readFileSync('leaf.key'),
  cert: fs.readFileSync('leaf.pem'),
};

https.createServer(options, (req, res) => {
  res.writeHead(200);
  res.end('hello world\n');
}).listen(8000);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].