Why my Spring OAuth2 Server not working using SSL self-sign ssl?
<p>I'm using OAuth 2.0 on my applications. I have 2 apps developed using Spring Boot, one the authentication with url <a href="https://192.168.1.30:2999/autenticador" rel="nofollow">https://192.168.1.30:2999/autenticador</a> and the second, the client, <a href="https://192.168.1.30:2901/" rel="nofollow">https://192.168.1.30:2901/</a>.</p>

<p>When I'm using the <strong>server without SSL</strong> (<a href="http://192.168.1.30:2999/autenticador" rel="nofollow">http://192.168.1.30:2999/autenticador</a> and <a href="https://192.168.1.30:2901/" rel="nofollow">https://192.168.1.30:2901/</a>) the authorization <strong>has success</strong>. But, <strong>when I'm using self-sign certificate</strong> I have problems, returning <strong>error 401, Unauthorized</strong>, Authentication Failed: Could not obtain access token. I don't know how and why it's happening.</p>

<p>Observation: The certificate is registred on my computer like trusted then I'm seeing the address bar green.</p>

<p>The client:</p>

<pre><code>@SpringBootApplication
@EnableOAuth2Sso
public class Application {
    public static void main(String[] args) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
        SpringApplication.run(Application.class, args);
    }
}
</code></pre>

<p>The OAuth 2.0 configuration on server:</p>

<pre><code>@Configuration
@EnableAuthorizationServer
public class OAuthConfiguration extends AuthorizationServerConfigurerAdapter{
    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
         endpoints.authenticationManager(authenticationManager);
    }

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
        .withClient("client")
        .authorizedGrantTypes("authorization_code")
        .scopes("read", "trust")
        .resourceIds("RESOURCE_ID")
        .secret("secret");
    }
}
</code></pre>

<p>Here is the Log of client after login success on server:</p>

<pre><code>  2016-06-06 16:47:27.376  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
  2016-06-06 16:47:27.377  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  2016-06-06 16:47:27.378  DEBUG  [nio-2901-exec-4]  w.c.HttpSessionSecurityContextRepository   No HttpSession currently exists
  2016-06-06 16:47:27.378  DEBUG  [nio-2901-exec-4]  w.c.HttpSessionSecurityContextRepository   No SecurityContext was available from the HttpSession: null. A new one will be created.
  2016-06-06 16:47:27.381  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
  2016-06-06 16:47:27.382  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 4 of 12 in additional filter chain; firing Filter: 'CsrfFilter'
  2016-06-06 16:47:27.383  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 5 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
  2016-06-06 16:47:27.383  DEBUG  [nio-2901-exec-4]  o.s.s.w.u.matcher.AntPathRequestMatcher    Request 'GET /' doesn't match 'POST /logout
  2016-06-06 16:47:27.383  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 6 of 12 in additional filter chain; firing Filter: 'OAuth2ClientAuthenticationProcessingFilter'
  2016-06-06 16:47:27.384  DEBUG  [nio-2901-exec-4]  o.s.s.w.u.matcher.AntPathRequestMatcher    Checking match of request : '/'; against '/login'
  2016-06-06 16:47:27.384  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
  2016-06-06 16:47:27.384  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 8 of 12 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
  2016-06-06 16:47:27.386  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 9 of 12 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
  2016-06-06 16:47:27.389  DEBUG  [nio-2901-exec-4]  o.s.s.w.a.AnonymousAuthenticationFilter    Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@9055e4a6: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 192.168.1.30; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
  2016-06-06 16:47:27.389  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 10 of 12 in additional filter chain; firing Filter: 'SessionManagementFilter'
  2016-06-06 16:47:27.389  DEBUG  [nio-2901-exec-4]  o.s.s.w.session.SessionManagementFilter    Requested session ID CBA2CC9F09D613F91D95FD4764E48A50 is invalid.
  2016-06-06 16:47:27.389  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 11 of 12 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
  2016-06-06 16:47:27.389  DEBUG  [nio-2901-exec-4]  o.s.security.web.FilterChainProxy          / at position 12 of 12 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
  2016-06-06 16:47:27.390  DEBUG  [nio-2901-exec-4]  o.s.s.w.a.i.FilterSecurityInterceptor      Secure object: FilterInvocation: URL: /; Attributes: [authenticated]
  2016-06-06 16:47:27.390  DEBUG  [nio-2901-exec-4]  o.s.s.w.a.i.FilterSecurityInterceptor      Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@9055e4a6: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 192.168.1.30; SessionId: null; Granted Authorities: ROLE_ANONYMOUS
  2016-06-06 16:47:27.399  DEBUG  [nio-2901-exec-4]  o.s.s.access.vote.AffirmativeBased         Voter: org.springframework.security.web.access.expression.WebExpressionVoter@3fcae110, returned: -1
  2016-06-06 16:47:27.404  DEBUG  [nio-2901-exec-4]  o.s.s.w.a.ExceptionTranslationFilter       Access is denied (user is anonymous); redirecting to authentication entry point

org.springframework.security.access.AccessDeniedException: Access is denied
</code></pre>