private boolean saveNewRootCAKeypair() { try { LOG.debug("Generating root CA public/private keys"); final KeyPair keyPair = CertUtils.generateRandomKeyPair(2 * CAManager.CertKeySize.value()); if (!configDao.update(rootCAPublicKey.key(), rootCAPublicKey.category(), CertUtils.publicKeyToPem(keyPair.getPublic()))) { LOG.error("Failed to save RootCA public key"); } if (!configDao.update(rootCAPrivateKey.key(), rootCAPrivateKey.category(), CertUtils.privateKeyToPem(keyPair.getPrivate()))) { LOG.error("Failed to save RootCA private key"); } } catch (final NoSuchProviderException | NoSuchAlgorithmException | IOException e) { LOG.error("Failed to generate/save RootCA private/public keys due to exception:", e); } return loadRootCAKeyPair(); }
private boolean saveNewRootCACertificate() { if (caKeyPair == null) { throw new CloudRuntimeException("Cannot issue self-signed root CA certificate as CA keypair is not initialized"); } try { LOG.debug("Generating root CA certificate"); final X509Certificate rootCaCertificate = CertUtils.generateV3Certificate( null, caKeyPair, caKeyPair.getPublic(), rootCAIssuerDN.value(), CAManager.CertSignatureAlgorithm.value(), getCaValidityDays(), null, null); if (!configDao.update(rootCACertificate.key(), rootCACertificate.category(), CertUtils.x509CertificateToPem(rootCaCertificate))) { LOG.error("Failed to update RootCA public/x509 certificate"); } } catch (final CertificateException | NoSuchAlgorithmException | NoSuchProviderException | SignatureException | InvalidKeyException | OperatorCreationException | IOException e) { LOG.error("Failed to generate RootCA certificate from private/public keys due to exception:", e); return false; } return loadRootCACertificate(); }
@Override public String getHashKey() { String value = HashKey.value(); if (value == null) { _configDao.getValueAndInitIfNotExist(HashKey.key(), HashKey.category(), getBase64EncodedRandomKey(128), HashKey.description()); } return HashKey.value(); }
@Override public String getEncryptionKey() { String value = EncryptionKey.value(); if (value == null) { _configDao.getValueAndInitIfNotExist(EncryptionKey.key(), EncryptionKey.category(), getBase64EncodedRandomKey(128), EncryptionKey.description()); } return EncryptionKey.value(); }
@Override public String getEncryptionIV() { String value = EncryptionIV.value(); if (value == null) { _configDao.getValueAndInitIfNotExist(EncryptionIV.key(), EncryptionIV.category(), getBase64EncodedRandomKey(128), EncryptionIV.description()); } return EncryptionIV.value(); }
public ConfigurationVO(String component, ConfigKey<?> key) { this(key.category(), "DEFAULT", component, key.key(), key.defaultValue(), key.description()); defaultValue = key.defaultValue(); dynamic = key.isDynamic(); scope = key.scope() != null ? key.scope().toString() : null; }
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist"); catergory = _configDepot.get(name).category(); } else { catergory = config.getCategory();