Skip to content

Instantly share code, notes, and snippets.

@dcmwong
dcmwong / displayCert.sh
Created May 21, 2021 09:23
Displaying inside a certificate
openssl x509 -in public.crt -text -noout
@dcmwong
dcmwong / sendMessage.js
Last active May 21, 2021 09:03
simple send message to tls server
import * as fs from 'fs'
import * as tls from 'tls'
var conn = tls.connect(1234, 'localhost', {}, function () {
if (conn.authorized) {
console.log('Connection authorized by a Certificate Authority.')
conn.write('hello from the client')
} else {
console.log('Connection not authorized: ' + conn.authorizationError)
}
@dcmwong
dcmwong / tlsServer.js
Created May 21, 2021 08:58
Simple TLS server
import * as http from 'http'
import * as fs from 'fs'
import * as net from 'net'
import * as tls from 'tls'
const options = {
cert: fs.readFileSync('server.crt'),
key: fs.readFileSync('server.key'),
// ca: [fs.readFileSync('public2crt'), fs.readFileSync('public.crt')],
ca: fs.readFileSync('public.crt'),
#!/bin/bash
# Private key for the root cert
openssl genrsa -out private.key 4096
# root certificate
openssl req -x509 -new -nodes -key private.key -subj "/C=<YOUR COUNTRY CODE>/ST=<YOUR STATE>/O=<YOUR ORG>/CN=<YOUR DOMAIN>" -sha256 -days 365 -out public.crt
# Private key for the server cert
openssl genrsa -out server.key 2048
import getAction from './';
test('action -> creates Customer', () => {
const actionName = 'someAction';
const action = getAction(actionName);
expect(action).toEqual('/actions/SomeAction');
});
import getAction from './';
test('action -> creates Customer', () => {
const createCustomerAction = getAction('addCustomer');
expect(createCustomerAction).toEqual('/actions/AddCustomer');
});
test('action -> edit Customer', () => {
const editCustomerAction = getAction('editCustomer');
expect(editCustomerAction).toEqual('/actions/EditCustomer');
const addCustomerAction = getAction('addCustomer');
const editCustomerAction = getAction('editCustomer');
const deleteCustomerAction = getAction('deleteCustomer');
const addCustomerAction = getAction('addCustomer');
const editCustomerAction = getAction('editCustomer');
const deleteCustomerAction = getAction('deleteCustomer');