Skip to content

Instantly share code, notes, and snippets.

View pmtabe1's full-sized avatar

Paul Msegeya pmtabe1

View GitHub Profile
@pmtabe1
pmtabe1 / tls-client.go
Created December 13, 2022 12:55 — forked from michaljemala/tls-client.go
SSL Client Authentication Golang sample
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)

The default format of keys was changed in OpenSSL 1.0. From OpenSSL 1.0 change log:

Make PKCS#8 the default write format for private keys, replacing the traditional format. This form is standardised, more secure and doesn't include an implicit MD5 dependency. [Steve Henson]

Good explanations of the difference between the two formats: https://tls.mbed.org/kb/cryptography/asn1-key-structures-in-der-and-pem

Converting RSA private key:

@pmtabe1
pmtabe1 / rsa.go
Created October 15, 2022 17:39 — forked from sohamkamani/rsa.go
Example of RSA encryption, decryption, signing, and verification in Go
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"fmt"
)
@pmtabe1
pmtabe1 / golang-tls.md
Created October 15, 2022 16:12 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@pmtabe1
pmtabe1 / docker-compose-v1.yml
Created August 17, 2022 10:58 — forked from markheath/docker-compose-v1.yml
Elasticsearch docker compose examples
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.1
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
@pmtabe1
pmtabe1 / Makefile
Created June 5, 2022 11:48 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@pmtabe1
pmtabe1 / time_format.go
Created November 18, 2021 17:32 — forked from ik5/time_format.go
A full example of all possible time formats in Golang
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Times: ")
t := time.Now()