Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save velfundert/66e179bffec2712bc949eed4bba9c1af to your computer and use it in GitHub Desktop.
Save velfundert/66e179bffec2712bc949eed4bba9c1af to your computer and use it in GitHub Desktop.
// Last sertifikat fra fil, og bygg klient:
String passord = "password";
InputStream sertifikat = new FileInputStream("cert.p12");
DigipostUserDocumentClient client = new Builder(AVSENDERS_KONTOID, sertifikat, passord)
.serviceEndpoint(new URI("https://..."))
.build();
/* ********* */
// Last sertifikat fra keystore (populert med keytool), og bygg klient:
String keyStorePassord = "KeystorePassord"
String keyPassord = "passord for sertifikat";
InputStream sertifikat = new FileInputStream("keystore.jks");
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(sertifikat, keyStorePassord.toCharArray());
sertifikat.close();
String onlyKeyAlias = keyStore.aliases().nextElement();
PrivateKey key = (PrivateKey) keyStore.getKey(onlyKeyAlias, keyPassord.toCharArray());
DigipostUserDocumentClient client = new Builder(AVSENDERS_KONTOID, key)
.serviceEndpoint(new URI("https://..."))
.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment