scalaj-http icon indicating copy to clipboard operation
scalaj-http copied to clipboard

SNI not set

Open jkransen opened this issue 7 years ago • 1 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?

jkransen avatar Jun 15 '18 16:06 jkransen

I think using HttpOptions.allowUnsafeSSL is related to this.

Are you using that because you're getting cert chain errors without it? I know that some JVMs ship without Let's Encrypt root certs

On Fri, Jun 15, 2018 at 12:33 PM Jeroen Kransen [email protected] wrote:

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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/scalaj/scalaj-http/issues/168, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfWCjynMiXUxDREpwVjs113uJ3ZzFQks5t8-HngaJpZM4Up1xf .

hoffrocket avatar Jun 19 '18 14:06 hoffrocket