go-acme / lego

Let's Encrypt/ACME client and library written in Go
https://go-acme.github.io/lego/
MIT License
7.46k stars 986 forks source link

S3 with custom endpoint #2043

Open yu-re-ka opened 8 months ago

yu-re-ka commented 8 months ago

Welcome

How do you use lego?

Binary

Detailed Description

1970 added S3 support for HTTP domain validation, but this is AWS s3 exclusive, as lego does not expose a way to specify a custom s3 endpoint.

Yes, I have a patch locally:


File: ../nixfiles/pkgs/lego.diff
diff --git a/providers/http/s3/s3.go b/providers/http/s3/s3.go
index d8fc4246..84bf3c46 100644
--- a/providers/http/s3/s3.go
+++ b/providers/http/s3/s3.go
@@ -5,6 +5,7 @@ import (
    "bytes"
    "context"
    "fmt"
+   "os"
    "strings"

    "github.com/aws/aws-sdk-go-v2/aws"
@@ -33,7 +34,11 @@ func NewHTTPProvider(bucket string) (*HTTPProvider, error) {
        return nil, fmt.Errorf("s3: unable to create AWS config: %w", err)
    }

-   client := s3.NewFromConfig(cfg)
+   client := s3.NewFromConfig(cfg, func(o *s3.Options) {
+       o.EndpointResolver = s3.EndpointResolverFromURL(os.Getenv("AWS_ENDPOINT_URL"), func (e *aws.Endpoint) {
+           e.HostnameImmutable = true
+       })
+   })

    return &HTTPProvider{
        bucket: bucket,
ldez commented 8 months ago

Hello,

I think you can open PR based on your suggestion.

ldez commented 6 months ago

@yu-re-ka any news?

yu-re-ka commented 6 months ago

Hi, I don't think the patch I made is universal enough to be useful. There is many options that the user might need to set, like HostnameImmutable, and I don't know how to integrate that.