如何强制Grails使用带有run-app或run-war的签名证书

时间:2014-10-17 14:57:21

标签: grails groovy

即使将此代码添加到Config.groovy后,Grails也坚持使用自己的自签名证书:

grails.tomcat.truststorePath = "${grailsSettings.baseDir}/conf/ssl/truststore.jks"
grails.tomcat.truststorePassword = "changeit"
grails.tomcat.clientAuth = "want"
grails.tomcat.keystorePath = "${grailsSettings.baseDir}/conf/ssl/keystore.jks"
grails.tomcat.keystorePassword = "changeit"
grails.tomcat.keyAlias = "localhost"

知道如何强制Grails在这里使用真正的密钥库吗?

2 个答案:

答案 0 :(得分:4)

显然,common mistake将这些设置放在Config.groovy中。它们属于BuildConfig.groovy。一旦我将它们放入BuildConfig.groovy,一切都适合我。

答案 1 :(得分:0)

我无法让您的示例工作或弄清楚如何在BuildConfig.groovy中设置任何属性,但对于grails 2.5.0,这对我来说是scripts/_Events.groovy

eventConfigureTomcat = { org.apache.catalina.startup.Tomcat tomcat ->
    if (Environment.getCurrent() == Environment.DEVELOPMENT) {
        System.setProperty("javax.net.debug", "ssl") //use this to confirm grails adds proper keystore/truststore settings
        System.setProperty("javax.net.ssl.keyStoreType", "jks")
        System.setProperty("javax.net.ssl.keyStore", "/absolute/path/to/keystore")
        System.setProperty("javax.net.ssl.keyStorePassword", "<_password_>")
        System.setProperty("javax.net.ssl.trustStoreType", "jks")
        System.setProperty("javax.net.ssl.trustStore", "/absolute/path/to/truststore")
        System.setProperty("javax.net.ssl.trustStorePassword", "<_password_>")
        println "SSL configuration complete"
    }
}