How to provide certificate and key along with the PUT request in scala

54 Views Asked by At

I want to provide certificate and key along with the PUT request in scala without using any external libraries (eg. akka). I don't have access to key tool so can't add certificate using Keytool.

I have below code that works for a simple HTTP GET request. How do I modify this code to provide certificate without using any external library or keystore for a HTTPS request.

import org.apache.http.impl.client.HttpClients
import org.apache.http.client.methods.HttpGet
import org.apache.http.util.EntityUtils
import org.apache.http.HttpHeaders
import org.apache.http.message.BasicHeader
import org.apache.spark.sql.SparkSession

val httpClient = HttpClients.createDefault()
val request = new HttpGet("http://localhost:30000/temp/")
val response = httpClient.execute(request)
val statusCode = response.getStatusLine.getStatusCode
val entity = response.getEntity
val responseData = EntityUtils.toString(entity)
println(responseData)
httpClient.close()
0

There are 0 best solutions below