Skip to content

Instantly share code, notes, and snippets.

View jamesidw's full-sized avatar

Sidney Wasibani jamesidw

View GitHub Profile
String getSignature(String jsonBody) throws IOException {
try (FileInputStream ksFile = new FileInputStream(keyStorePath)) {
KeyStore ks = KeyStore.getInstance("PKCS12");
ks.load(ksFile, keyPassword.toCharArray());
// there may be more than one key in the keystore...here we are picking the 'dev' key
var pk = ks.getKey("dev", keyPassword.toCharArray());
Signature ps = Signature.getInstance("SHA256withRSA");
ps.initSign((PrivateKey) pk);