How can i use the following code in grails --
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
return;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
return;
}
}
};
The above code is working perfectly fine when i run the same code in a JAVA project but Grails is not compiling the code and giving error -- No expression for the array constructor call on the first line.
The following piece of code will work:
import javax.net.ssl.X509TrustManager
import javax.net.ssl.TrustManager
import java.security.cert.X509Certificate
import java.security.cert.CertificateException
def trustAllCerts = [
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null
}
public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
}
public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
}
}
] as TrustManager[]
Have a look at this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With