Skip to content

Instantly share code, notes, and snippets.

View mrhockeymonkey's full-sized avatar
😀
Making my own x-plat app with Flutter

Scott Matthews mrhockeymonkey

😀
Making my own x-plat app with Flutter
View GitHub Profile
@mrhockeymonkey
mrhockeymonkey / dynamic-dynamic-params.ps1
Created February 12, 2020 09:38
Dynamically define dynamic parameters for Powershell functions
function Verb-Noun {
[CmdletBinding()]
param (
# a normal parameter
[Parameter(ValueFromPipeline = $true)]
[System.String]$Name,
)
dynamicparam {
# a simple dynamic parameter, $PossibleCategories is discovered on module import
$DynamicParams = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
@mrhockeymonkey
mrhockeymonkey / verify_certificate.py
Last active March 16, 2024 02:11
Verify certificates with Python
from base64 import b64decode
from OpenSSL import crypto
def verify_chain_of_trust(certificate, trusted_cert_pems):
# Create and fill a X509Sore with trusted certs
store = crypto.X509Store()
for trusted_cert_pem in trusted_cert_pems:
trusted_cert = crypto.load_certificate(crypto.FILETYPE_PEM, trusted_cert_pem)
store.add_cert(trusted_cert)
@mrhockeymonkey
mrhockeymonkey / openssl-example.ps1
Last active March 16, 2024 02:11
OpenSSL Example Usages
# example creating certs for use with docker swarm
$openssl = 'C:\Program Files (x86)\OpenSSL\1.0.1L\bin\openssl.exe'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
$CN = "some-cert-name"
$Fqdn = "computer1.com"
# create a CA
& $openssl genrsa -aes256 -out ca-key.pem 4096
& $openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem -subj "/CN=$CN"