// set the DH parameter for empherial and anon cipher suites
serverContext.setDHParameter(dhparam);
KeyAndCertificate kac;
EncryptedPrivateKeyInfo epki;
String password = getPassword("Certificate password");
try {
kac = new KeyAndCertificate(certDir + "/serverRSA1024.pem");
epki = (EncryptedPrivateKeyInfo)kac.getPrivateKey();
epki.decrypt(password);
serverContext.setRSACertificate(kac.getCertificateChain(), (RSAPrivateKey)epki.getPrivateKeyInfo());
} catch (Exception ex) {
System.out.println("Unable to set RSA server certificate.");
System.out.println("RSA cipher-suites can not be used. " + ex);
}
try {
// set the DSA certificate/private key for DSA cipher suites
kac = new KeyAndCertificate(certDir + "/serverDSA1024.pem");
epki = (EncryptedPrivateKeyInfo)kac.getPrivateKey();
epki.decrypt(password);
serverContext.setDSACertificate(kac.getCertificateChain(), epki.getPrivateKeyInfo());
} catch (Exception ex) {
System.out.println("Unable to set DSA server certificate.");
System.out.println("DSA cipher-suites can not be used. " + ex);
}
try {
// set the DH certificate/private key for DH cipher suites
kac = new KeyAndCertificate(certDir + "/serverDH1024.pem");
epki = (EncryptedPrivateKeyInfo)kac.getPrivateKey();
epki.decrypt(password);
serverContext.setDHCertificate(kac.getCertificateChain(), epki.getPrivateKeyInfo());
} catch (Exception ex) {
System.out.println("Unable to set Diffie-Hellman server certificate.");
System.out.println("Diffie-Hellman cipher-suites can not be used. " + ex);
}