scalaj / scalaj-http

Simple scala wrapper for HttpURLConnection. OAuth included.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SNI not set

jkransen opened this issue · comments

This is the code I use to connect to a remote server:

val postUrl = "https://api.luftdaten.info/v1/push-sensor-data/"
val response = Http(postUrl).headers(Seq("X-PIN" -> "1", "X-Sensor" -> s"fijnstof-${report.id}")).postForm(Seq("P1" -> report.pm10.toString, "P2" -> report.pm25.toString)).option(HttpOptions.allowUnsafeSSL).asString
log.debug(s"Luftdaten: $response")

The response I get is a 403 Forbidden with:

Reason: The client software did not provide a hostname using Server Name Indication (SNI), which is required to access this server.`

I tried setting System.setProperty("jsse.enableSNIExtension", "true"), even though the underlying java.net.HttpsURLConnection is said to default to true.

Is this a bug, or am I missing something?