Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring gradle jetty plugin to use ssl

Tags:

ssl

gradle

jetty

I've been trying to set up ssl with the gradle jetty plugin with no success. Also I've been unsuccessful in finding documentation related to it. Is there someone out there who can point me in the right direction to it?

EDIT

As part of the search I found out the following sample

jettyRun {
    def httpConnector = new org.mortbay.jetty.nio.SelectChannelConnector();
    httpConnector.port = 8080
    def httpsConnector = new org.mortbay.jetty.security.SslSocketConnector();
    httpsConnector.port = 8443
    httpsConnector.keystore = "keystore.jks"
    httpsConnector.keyPassword = "keystorepwd"
    httpsConnector.truststore = "cacerts"
    httpsConnector.trustPassword = "cacertspwd"
    connectors [httpConnector, httpsConnector]
}

But following that sample, left me with the following problem...

unable to resolve class org.mortbay.jetty.nio.SelectChannelConnector 
unable to resolve class org.mortbay.jetty.security.SslSocketConnector

Does I have to add some dependency in the build process. I've looked at the jar files as part of my gradle distribution and all seems correct.

EDIT 2

I have fixed the issue with the classpath, by adding the following

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.mortbay.jetty:jetty:6.1.25'
    }
}

But now gradle complaints with the following message:

Cannot cast object '[email protected]:8080' with class 'org.mortbay.jetty.nio.SelectChannelConnector' to class 'org.mortbay.jetty.Connector'

If anyone seems to have found an answer I would greatly appreciate!

like image 627
Angel Villalain Avatar asked Nov 27 '25 06:11

Angel Villalain


1 Answers

You could greatly simplify SSL/HTTPS part of your gradle scripts by using Gretty gradle plugin instead of Jetty plugin.

It supports HTTPS with a single-line instruction:

gretty.httpsEnabled = true

It also provides lot of other useful functions, all documented at Gretty documentation site.

Disclosure: I am author of Gretty plugin.

like image 98
akhikhl Avatar answered Dec 01 '25 15:12

akhikhl