Skip to content

Instantly share code, notes, and snippets.

set OPENSSL_CONF=C:\path\to\openssl.cnf
set PATH=C:\path\to\openssl\;%PATH%
:: new key and CSR
openssl req -newkey rsa:4096 -sha256 -keyout PRIVATEKEY.key -out CSR.csr
openssl req -newkey rsa:4096 -sha256 -keyout PRIVATEKEY.key -out CSR.csr -subj "/C=CZ/L=City/O=Company/OU=My Department/CN=%NAME%"
:: new CSR from existing key
openssl req -new -sha256 -key key.key -out csr.csr
@McLaynV
McLaynV / AuthorityInfoAccess-composer.js
Last active February 14, 2024 17:51
AuthorityInfoAccess (AIA) composer/generator
/*
This is a script for generating AuthorityInfoAccess (AIA) x.509 certificate extension value.
AIA can contain CA certificate URi and OCSP URI.
This script has 2 sections. Do not touch the first section, customize the second section.
Then just copy it to a browser JavaScript console (F12 in my favorite browsers).
It has some limitations. If you hit them or find a bug, let me know.
For example, I didn't find what the AIA structurce should look like in the case of multiple OCSP URIs or multiple CA certificate URIs. If you need it, find me a valid AIA value example.
@McLaynV
McLaynV / pkcs11-spy.2.log
Created August 9, 2023 15:17
`pkcs11-tool --list-objects -y privkey` doesn't list private keys with some PKCS#11 tokens
*************** OpenSC PKCS#11 spy *****************
Loaded: "C:\Windows\System32\p11rss.dll"
0: C_GetInterface
P:13588; T:13672 2023-08-09 17:09:28.806
[compat]
[in] pInterfaceName 00007ff7e75e60d8 / 7
00000000 50 4B 43 53 20 31 31 PKCS 11
[in] pVersion = NULL
[in] flags =
@McLaynV
McLaynV / pkcs11-spy.1.log
Last active August 2, 2023 15:21
`pkcs11-tool --list-objects -y privkey` doesn't list private keys with some PKCS#11 tokens
*************** OpenSC PKCS#11 spy *****************
Loaded: "C:\Windows\System32\p11rss.dll"
0: C_GetInterface
2023-08-02 17:14:07.533
[compat]
[in] pInterfaceName 00007ff6a11960e0 / 7
00000000 50 4B 43 53 20 31 31 PKCS 11
[in] pVersion = NULL
[in] flags =
@McLaynV
McLaynV / pkcs11-spy.0.log
Last active August 2, 2023 15:20
`pkcs11-tool --list-objects` doesn't list private keys with some PKCS#11 tokens
*************** OpenSC PKCS#11 spy *****************
Loaded: "C:\Windows\System32\p11rss.dll"
0: C_GetInterface
2023-07-07 15:22:47.066
[compat]
[in] pInterfaceName 00007ff6601560e0 / 7
00000000 50 4B 43 53 20 31 31 PKCS 11
[in] pVersion = NULL
[in] flags =
# extract sub-repository from a git repository
pip3 install git-filter-repo
git clone https://github.com/ACCOUNT/OLD_REPO.git
mv MY_GIT_DIR\ACCOUNT\OLD_REPO MY_GIT_DIR\ACCOUNT\NEW_REPO
cd MY_GIT_DIR\ACCOUNT\NEW_REPO
git filter-repo --force --path PATH_TO_KEEP --path "ANOTHER PATH TO KEEP" --path PATH/TO/BE/KEPT
@McLaynV
McLaynV / rwlock.py
Created June 1, 2022 05:04 — forked from tylerneylon/rwlock.py
A simple read-write lock implementation in Python.
# -*- coding: utf-8 -*-
""" rwlock.py
A class to implement read-write locks on top of the standard threading
library.
This is implemented with two mutexes (threading.Lock instances) as per this
wikipedia pseudocode:
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Using_two_mutexes