0

I'm trying to implement a gradle task that sends a HTTPS request to my backend. For authentication, I have to attach a client certificate to the request.

Does anybody know how to do this? I'm currently using the library http-builder-ng but haven't figured out yet to achieve this.

phoebus
  • 1,280
  • 1
  • 16
  • 36

1 Answers1

1

Well I dont know your library but is sh an option for you? Gradle features an Exec task to execute shell as task.

You could do curl there:

curl -v \
  --cacert ./ca.pem \
  --key ./admin-key.pem \
  --cert ./admin.pem \
  https://xxxx/api/v1/

In build.gradle it could look like this: (url is a gradle project property, can be given via -P flag during build or in gradle.properties.)

task httpsRequest(type:Exec) {
commandLine 'sh', '-c', "curl -v --cacert ./ca.pem --key ./admin-key.pem --cert ./admin.pem '${url}'"
}
LeonG
  • 430
  • 3
  • 14