Can you set S3 path in Micronaut Key Store Path?

107 Views Asked by At

I have a lambda application that uses Micronaut 3.9.x (Migrated from Micronaut 1) which uses HttpClient and has a SSL configuration that points to a certificate inside my resources folder. I have the variable micronaut.http.client.ssl.key.store.path in environment variable. Can I set this to a path in S3 bucket say s3://mys3bucket/certs/client.p12?

What are the permissions that I need to add in Lambda role? TIA

1

There are 1 best solutions below

0
sorin.silaghi On

You can create a class to replace NettyClientSslBuilder. You can then overwrite the load() method, and get the key store from wherever you want.

@Slf4j
@Singleton
@Replaces(NettyClientSslBuilder.class)
public class CustomClientSslBuilder extends NettyClientSslBuilder {

    @Override
    protected KeyStore load(Optional<String> optionalType, String resource, Optional<String> optionalPassword) throws Exception {
        ...
        retrun keystore;
    }

}

If you want to do this on Micronaut 4.x, make sure you add netty-incubator-codec-http3 as a dependency or else annotation processor fails on that class. This is because the class that it extends implements experimental support for HTTP 3, and requires that library to build. I filled a bug report for this: https://github.com/micronaut-projects/micronaut-core/issues/10354