Use KeyUtils
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.athenz.instanceproviderservice;
+import com.yahoo.security.KeyAlgorithm;
+import com.yahoo.security.KeyUtils;
+
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
@@ -15,13 +18,7 @@ public class AutoGeneratedKeyProvider implements KeyProvider {
private final KeyPair keyPair;
public AutoGeneratedKeyProvider() {
- try {
- KeyPairGenerator rsa = KeyPairGenerator.getInstance("RSA");
- rsa.initialize(2048);
- keyPair = rsa.genKeyPair();
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
+ keyPair = KeyUtils.generateKeypair(KeyAlgorithm.RSA, 2048);
}
@Override
