Skip to content

Instantly share code, notes, and snippets.

@GaetanoPiazzolla
Created October 27, 2021 16:45
Show Gist options
  • Save GaetanoPiazzolla/806f86586bd8e3b2c24eae9ac743ef4f to your computer and use it in GitHub Desktop.
Save GaetanoPiazzolla/806f86586bd8e3b2c24eae9ac743ef4f to your computer and use it in GitHub Desktop.
private static void fetchCertificate(String resumeToken, List<String> possibleKids) throws CertificateException, IOException {
System.out.println("Fetching new certificate");
// rest call
Response<String> resp = apiCertificate.getCertUpdate(resumeToken).execute();
if (resp.isSuccessful()) {
var headers = resp.headers();
var responseKid = headers.get(HEADER_KID);
var newResumeToken = headers.get(HEADER_RESUME_TOKEN);
String keyString = resp.body();
if (keyString != null && !keyString.isBlank()) {
if (possibleKids.contains(responseKid)) {
PublicKey key = getPublicKey(keyString);
keyMap.put(responseKid, key);
} else {
System.out.println(".....mumble.... this should never happen");
}
fetchCertificate(newResumeToken, possibleKids);
}
}
}
@GaetanoPiazzolla
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment