通过 Alpakka 将文件上传到 AWS S3 期间发生 SSLHandshakeException

SSLHandshakeException happens during file upload to AWS S3 via Alpakka

我正在尝试设置一个 Alpakka S3 用于文件上传。这是我的配置:

alpakka s3 依赖:

...
"com.lightbend.akka" %% "akka-stream-alpakka-s3" % "0.20"
...

这里是application.conf:

akka.stream.alpakka.s3 {
  buffer = "memory"
  proxy {
    host = ""
    port = 8000
    secure = true
  }
  aws {
    credentials {
      provider = default
    }
  }
  path-style-access = false
  list-bucket-api-version = 2
}

文件上传代码示例:

private val awsCredentials = new BasicAWSCredentials("my_key", "my_secret_key")
private val awsCredentialsProvider = new AWSStaticCredentialsProvider(awsCredentials)
private val regionProvider = new AwsRegionProvider { def getRegion: String = "us-east-1" }
private val settings = new S3Settings(MemoryBufferType, None, awsCredentialsProvider, regionProvider, false, None, ListBucketVersion2)
private val s3Client = new S3Client(settings)(system, materializer)

val fileSource = Source.fromFuture(ByteString("ololo blabla bla"))
val fileName = UUID.randomUUID().toString

val s3Sink: Sink[ByteString, Future[MultipartUploadResult]] = s3Client.multipartUpload("my_basket", fileName)

fileSource.runWith(s3Sink)
  .map { 
    result => println(s"${result.location}") 
  } recover {
    case ex: Exception =>  println(s"$ex")
  }

当我 运行 此代码时,我得到:

javax.net.ssl.SSLHandshakeException: General SSLEngine problem

可能是什么原因?

包含点的存储桶名称会出现证书问题。 你可以切换到 akka.stream.alpakka.s3.path-style-access = true 摆脱这个。

我们正在考虑将其设为默认值:https://github.com/akka/alpakka/issues/1152