spring-projects / spring-security-kerberos

Spring Security Kerberos
https://spring.io/projects/spring-security-kerberos
185 stars 227 forks source link

spring-security-kerberos doesn't support https #111

Open zjffdu opened 7 years ago

zjffdu commented 7 years ago

This is my sample code for using spring-security-kerberos under https. But I got 401 ERROR. I have verified the scenario of using kerberos + http and non-kerberos + https. Both of them works, but when I use it under kerberos + https, it would fail. Could anyone help on this ? Thanks

        SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
        httpClient = HttpClients.custom().setSSLSocketFactory(csf).build();
        return new KerberosRestTemplate(keytabLocation, principal, httpClient);
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 401 </title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing /sessions. Reason:
<pre>    Authentication required</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>
nunojun commented 6 years ago

KerberosRestTemplate creates its own HttpClient which has Kerberos support. If you pass your httpClient when you create an instance, it's replaced and the negotiation logic will be gone. The solution is referring to buildHttpClient() method in KerberosRestTemplate and adjust it when you create your HttpClient.

rwinch commented 6 years ago

@nunojun Thanks for your response. I will give some time to see if there is any additional problems and if not, close this.