Skip to content

Instantly share code, notes, and snippets.

openssl & certificates

A collection of openssl commands arround certificates.

Verify certificates

verify single certificate

openssl verify server.crt
#!/bin/bash
while read -r f
do
path=${f%/*}
file=${f##*/}
base=${file%%.*} # note needs $file
ext=${file#*.} # note needs $file
echo "$f ; $path ; $file ; $base ; $ext"
@commenthol
commenthol / loopback-models.js
Created September 21, 2018 18:51
convert loopback yaml models to json
/**
* convert models-yaml/*.yaml file to models/*.json
*/
/* eslint no-console: off */
const yaml = require('js-yaml')
const {resolve, basename} = require('path')
const fs = require('fs')
@commenthol
commenthol / httpError.js
Created July 15, 2018 18:28
http error
const {STATUS_CODES} = require('http')
/**
* HTTP Error
* @param {Number} status - http status code
* @param {String|Error} msg - message or error
* @param {String} [code] - optional code
* @return {Error} error
*/
const httpError = (status = 500, msg, code) => {
@commenthol
commenthol / server.js
Last active September 19, 2018 16:00
legacy server with logger, body-parser middlewares and connect runner
const http = require('http')
const logger = (req, res, next) => {
const time = Date.now()
res.on('finish', () => {
const {method, url, headers, body} = req
const {statusCode} = res
console.log('%s %s %s %s %j %s', method, url, statusCode, Date.now() - time, headers, JSON.stringify(body))
})
next()
@commenthol
commenthol / geany.sh
Created June 24, 2018 11:26
start exe files from cygwin
#!/bin/bash
exe=$(cygpath -u "C:\Program Files (x86)\Geany\bin\geany.exe")
args=""
while (( "$#" )); do
arg=$1
if [[ $arg == /* ]] ; then
arg=\"$(cygpath -a -w "$arg")\"
fi
#!/bin/bash
# rotate scanned pdf pages by 180°
# name all pages
help=$(cat <<EOS
Usage: rotate-pdf.sh IN.pdf OUT.pdf [PAGES]
Read from IN.pdf, rotate PAGES by 180° and write out to OUT.pdf
@commenthol
commenthol / test-ciphers.sh
Created July 13, 2017 16:47
Test Cipher Suites, find TLS Protocols
#!/usr/bin/env bash
#
# From https://superuser.com/questions/109213/how-do-i-list-the-ssl-tls-cipher-suites-a-particular-website-offers
#
# Find cipher suites a website offers
#
# Usage
#
@commenthol
commenthol / findrequire.sh
Created June 24, 2017 11:30
find all required packages in a directory
#!/bin/bash
# find all required packages in a directory
# usage
# findrequire src
# findrequire src | xargs npm i -S
# findrequire test | xargs npm i -D
find $1 -iname "*.js" |\
xargs egrep -h "require\(['][^.]" |\
sed "s/.*require('\([^'']*\)').*/\1/g" |\
egrep -v "^(assert|child|cluster|events|dgram|dns|domain|fs|http|https|inspector|net|os|path|punnycode|querystring|readline|stream|string_decoder|tls|tty|udp4|url|util|v8|vm|zlib)$" |\
@commenthol
commenthol / small-flux-demo.js
Last active June 20, 2017 21:01
small flux demo
const EventEmitter = require('events');
const random = () => ('' + Math.random()).substr(2)
class Dispatcher extends EventEmitter {
constructor () {
super()
this.token = `dispatch_${random()}`
this.dispatch = this.dispatch.bind(this)
}