<p>I'm trying to use the AWS S3 SDK for Java to connect to a bucket from a Kubernetes pod running an Spring Boot application. In order to get external access I had to create a service as follows:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: s3
  namespace: production
spec:
  type: ExternalName
  externalName: nyc3.digitaloceanspaces.com
</code></pre>

<p>And then I modified my configuration in <code>application.properties</code> specifying the endpoint:</p>

<pre><code>cloud.aws.endpoint=s3
cloud.aws.credentials.accessKey=ASD
cloud.aws.credentials.secretKey=123
cloud.aws.credentials.instanceProfile=true
cloud.aws.credentials.useDefaultAwsCredentialsChain=true
</code></pre>

<p>Because the SDK builds the host name for the bucket as <code>bucket.s3...</code> I modified my client to use "path style" access with this configuration:</p>

<pre><code>@Bean(name = "amazonS3")
public AmazonS3Client amazonS3Client(AWSCredentialsProvider credentialsProvider,
        RegionProvider regionProvider) {

    EndpointConfiguration endpointConfiguration = new EndpointConfiguration(
            endpoint, regionProvider.getRegion().getName());

    return (AmazonS3Client) AmazonS3ClientBuilder.standard()
                                .withCredentials(credentialsProvider)
                                .withEndpointConfiguration(endpointConfiguration)
                                .withPathStyleAccessEnabled(true)
                                .build();
}
</code></pre>

<p>But when I try to perform any bucket operation I get the following error regarding the name mismatch with the SSL certificate:</p>

<pre><code>javax.net.ssl.SSLPeerUnverifiedException: Certificate for &lt;s3&gt; doesn't match any of the subject alternative names: [*.nyc3.digitaloceanspaces.com, nyc3.digitaloceanspaces.com]
</code></pre>

<p>How can I avoid this certificate error?</p>

Joaquín L. Robles
<p>I am having a similar issue. I believe AmazonS3Client API doesn't resolve the k8s service name. I had to directly use a host name instead of K8s service name.</p>
