The sun.net.inetaddr.ttl property raises an AccessControlException

We use ReCaptchas in the Tomcat web application. Recently, we had several problems connecting to ReCaptcha calibration servers, and one thing that we looked at was to put a timeout in the resolution of the DNS record, as suggested by Wiki ReCaptcha: http: //wiki.recaptcha .net / index.php / Overview # Important: _DNS_Caching

After adding the sun.net.inetaddr.ttl property (set it to 5 minutes to start), we always get an AccessControlException when trying to validata captcha.

 java.security.AccessControlException: access denied (java.net.SocketPermission api-verify.recaptcha.net:80 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:323) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:904) at net.tanesha.recaptcha.http.SimpleHttpLoader.httpPost(SimpleHttpLoader.java:66) at net.tanesha.recaptcha.ReCaptchaImpl.checkAnswer(ReCaptchaImpl.java:61) 

Here is an excerpt from catalina.policy that we use:

 permission java.net.SocketPermission "*", "resolve"; permission java.net.SocketPermission "api-verify.recaptcha.net:80", "connect,resolve"; 

Now I do not expect that the DNS record on the ReCaptcha servers will change much (or in general), but rebooting the server if this happens is also not very good. Any ideas that trigger this behavior?

+4
source share

Source: https://habr.com/ru/post/1342563/


All Articles