/** * Uploads a server certificate to AWS IAM. * * @param name The server certificate name. No spaces. * @param path Path to store the certificate under. * @param body PEM-encoded certificate body. * @param chain PEM-encoded certificate chain. * @param key PEM-encoded certificate key. * @return The server certificate ID of the uploaded certificate. */ public String uploadServerCertificate( final String name, final String path, final String body, final String chain, final String key) { final UploadServerCertificateRequest request = new UploadServerCertificateRequest() .withServerCertificateName(name) .withPath(sanitizePath(path)) .withCertificateBody(body) .withCertificateChain(chain) .withPrivateKey(key); final UploadServerCertificateResult result = client.uploadServerCertificate(request); return result.getServerCertificateMetadata().getServerCertificateId(); }
public String loadSSLCertificate( String certificateName, String certificate, String privateKey, String path){ String certificateId = this.getCertificateId(certificateName); if(certificateId==null){ UploadServerCertificateRequest certificateRequest = new UploadServerCertificateRequest( certificateName, certificate, privateKey); certificateRequest.setPath(path); UploadServerCertificateResult uploadServerCertificate = getIdentityClient().uploadServerCertificate(certificateRequest); certificateId = uploadServerCertificate.getServerCertificateMetadata().getServerCertificateId(); } return certificateId; }
@Override public void execute(Context context) throws Exception { resource.remoteCert = AWS.iam.createServerCert(new UploadServerCertificateRequest() .withPath(ServerCert.certPath(context.env)) .withServerCertificateName(resource.name) .withCertificateBody(resource.certificate) .withPrivateKey(resource.privateKey) .withCertificateChain(resource.chain)); Threads.sleepRoughly(Duration.ofSeconds(10)); // wait 10 seconds to make cert visible to other system }
public ServerCertificate createServerCert(UploadServerCertificateRequest request) throws InterruptedException { logger.info("create server cert, path={}, name={}", request.getPath(), request.getServerCertificateName()); UploadServerCertificateResult result = iam.uploadServerCertificate(request); return new ServerCertificate(result.getServerCertificateMetadata(), request.getCertificateBody()) .withCertificateChain(request.getCertificateChain()); }