public static KeyManager[] keyManagerOf(X509Certificate cert, PrivateKey privateKey) {

    var pw = new char[0];

    try {
      var ks = KeyStore.getInstance(KeyStore.getDefaultType());
      ks.load(null);
      ks.setKeyEntry("client-auth", privateKey, pw, new java.security.cert.Certificate[] {cert});
      var kmf = KeyManagerFactory.getInstance("PKIX");
      kmf.init(ks, pw);
      return kmf.getKeyManagers();
    } catch (IOException | GeneralSecurityException e) {
      throw new IllegalArgumentException("failed to initialize client certificate store", e);
    }
  }
@Test
  void keyManager() throws Exception {

    var key = generateSigningKey(URI.create(ISSUER));

    // when
    var kms = TlsContext.keyManagerOf(key.getParsedX509CertChain().get(0), key.toPrivateKey());

    // then
    assertContainsCert(kms, key);
  }