Skip to content

Instantly share code, notes, and snippets.



Last active Mar 21, 2021
What would you like to do?
Récupérer le certificat public au format PEM à partir d'un JWKS
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
//DEPS org.bitbucket.b_c:jose4j:0.7.6
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import java.util.List;
import java.util.concurrent.Callable;
import org.jose4j.jwk.HttpsJwks;
import org.jose4j.jwk.JsonWebKey;
import org.jose4j.keys.RsaKeyUtil;
@Command(name = "GetKey", mixinStandardHelpOptions = true, version = "GetKey 0.1",
description = "GetKey made with jbang")
class GetKey implements Callable<Integer> {
@Parameters(index = "0", description = "URL vers JSON Web Key Sets (JWKS)")
private String url;
public static void main(String... args) {
int exitCode = new CommandLine(new GetKey()).execute(args);
public Integer call() throws Exception {
HttpsJwks jwks = new HttpsJwks(url);
List<JsonWebKey> liste = jwks.getJsonWebKeys();
for (JsonWebKey jsonWebKey : liste) {
String cert = RsaKeyUtil.pemEncode(jsonWebKey.getPublicKey());
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment