Search in sources :

Example 26 with HDDSKeyGenerator

use of org.apache.hadoop.hdds.security.x509.keys.HDDSKeyGenerator in project ozone by apache.

the class DefaultCertificateClient method createKeyPair.

protected KeyPair createKeyPair() throws CertificateException {
    HDDSKeyGenerator keyGenerator = new HDDSKeyGenerator(securityConfig);
    KeyPair keyPair = null;
    try {
        keyPair = keyGenerator.generateKey();
        keyCodec.writePublicKey(keyPair.getPublic());
        keyCodec.writePrivateKey(keyPair.getPrivate());
    } catch (NoSuchProviderException | NoSuchAlgorithmException | IOException e) {
        getLogger().error("Error while bootstrapping certificate client.", e);
        throw new CertificateException("Error while bootstrapping certificate.", BOOTSTRAP_ERROR);
    }
    return keyPair;
}
Also used : KeyPair(java.security.KeyPair) HDDSKeyGenerator(org.apache.hadoop.hdds.security.x509.keys.HDDSKeyGenerator) CertificateException(org.apache.hadoop.hdds.security.x509.exceptions.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) NoSuchProviderException(java.security.NoSuchProviderException)

Aggregations

HDDSKeyGenerator (org.apache.hadoop.hdds.security.x509.keys.HDDSKeyGenerator)25 KeyPair (java.security.KeyPair)17 Test (org.junit.Test)17 X509CertificateHolder (org.bouncycastle.cert.X509CertificateHolder)13 SecurityConfig (org.apache.hadoop.hdds.security.x509.SecurityConfig)11 PKCS10CertificationRequest (org.bouncycastle.pkcs.PKCS10CertificationRequest)10 CertificateSignRequest (org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest)9 DefaultProfile (org.apache.hadoop.hdds.security.x509.certificate.authority.PKIProfiles.DefaultProfile)6 LocalDate (java.time.LocalDate)5 KeyCodec (org.apache.hadoop.hdds.security.x509.keys.KeyCodec)5 X509Certificate (java.security.cert.X509Certificate)4 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)4 Before (org.junit.Before)4 File (java.io.File)3 IOException (java.io.IOException)3 SelfSignedCertificate (org.apache.hadoop.hdds.security.x509.certificates.utils.SelfSignedCertificate)3 Extension (org.bouncycastle.asn1.x509.Extension)3 SubjectPublicKeyInfo (org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)3 JcaX509CertificateConverter (org.bouncycastle.cert.jcajce.JcaX509CertificateConverter)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2