core/src/main/java/co/elastic/tealess/KeyStoreBuilder.java
// XXX: This only supports RSA keys right now.
This only supports RSA keys right now.
This only supports RSA keys right now .
public void addPrivateKeyPEM(Path keyPath, Path certificatePath) throws IOException, Bug, ConfigurationProblem {
    PrivateKey key;
    try {
      key = KeyStoreUtils.loadPrivateKeyPEM(keyPath);
    } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
      throw new Bug("Unexpected problem when loading private key.", e);
    }
    Collection<? extends Certificate> certificates;
    try {
      certificates = parseCertificatesPath(certificatePath);
    } catch (CertificateException e) {
      throw new ConfigurationProblem("Failure loading certificates from " + certificatePath, e);
    }
    try {
      logger.info("Adding key+cert named '{}' to internal keystore.", "mykey");
      keyStore.setKeyEntry("mykey", key, IN_MEMORY_KEYSTORE_PASSPHRASE, certificates.toArray(new Certificate[0]));
      keyManagerFactory.init(keyStore, IN_MEMORY_KEYSTORE_PASSPHRASE);
    } catch (KeyStoreException e) {
      throw new Bug("Failure trying to setKeyEntry in the in-memory keystore", e);
    } catch (UnrecoverableKeyException e) {
      throw new Bug("Corrupt or invalid keystore passphrase? This is a bug (since we are forming the keystore in-memory!", e);
    } catch (NoSuchAlgorithmException e) {
      throw new Bug("No such algorithm?", e);
    }
    modified = true;
  }
public void addPrivateKeyPEM ( Path keyPath , Path certificatePath ) throws IOException , Bug , ConfigurationProblem { PrivateKey key ; try { key = KeyStoreUtils . loadPrivateKeyPEM ( keyPath ) ; } catch ( NoSuchAlgorithmException | InvalidKeySpecException e ) { throw new Bug ( "Unexpected problem when loading private key." , e ) ; } Collection < ? extends Certificate > certificates ; try { certificates = parseCertificatesPath ( certificatePath ) ; } catch ( CertificateException e ) { throw new ConfigurationProblem ( "Failure loading certificates from " + certificatePath , e ) ; } try { logger . info ( "Adding key+cert named '{}' to internal keystore." , "mykey" ) ; keyStore . setKeyEntry ( "mykey" , key , IN_MEMORY_KEYSTORE_PASSPHRASE , certificates . toArray ( new Certificate [ 0 ] ) ) ; keyManagerFactory . init ( keyStore , IN_MEMORY_KEYSTORE_PASSPHRASE ) ; } catch ( KeyStoreException e ) { throw new Bug ( "Failure trying to setKeyEntry in the in-memory keystore" , e ) ; } catch ( UnrecoverableKeyException e ) { throw new Bug ( "Corrupt or invalid keystore passphrase? This is a bug (since we are forming the keystore in-memory!" , e ) ; } catch ( NoSuchAlgorithmException e ) { throw new Bug ( "No such algorithm?" , e ) ; } modified = true ; }
XXX: This only supports RSA keys right now.
XXX : This only supports RSA keys right now .