spring-cloud-security-oauth2-jwt icon indicating copy to clipboard operation
spring-cloud-security-oauth2-jwt copied to clipboard

OAuth2Configuration.java 中,直接加载jks的方式为什么屏蔽了,可以使用吗

Open junneyang opened this issue 7 years ago • 3 comments

    @Bean
    public TokenStore tokenStore() {
        return new JwtTokenStore(jwtTokenEnhancer());
    }

    //    @Bean
    //    protected JwtAccessTokenConverter jwtTokenEnhancer() {
    //    KeyStoreKeyFactory keyStoreKeyFactory =
    //            new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"), "mySecretKey".toCharArray());
    //        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    //        converter.setKeyPair(keyStoreKeyFactory.getKeyPair("jwt"));
    //        return converter;
    //    }

    @Bean
    protected JwtAccessTokenConverter jwtTokenEnhancer() {
        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
        converter.setSigningKey("123");
        return converter;
    }
}

junneyang avatar Sep 06 '17 05:09 junneyang

应该是可以的,时间比较久了,你试一下吧,有问题再留言。我抽时间再看一下。

jiangchao123 avatar Sep 06 '17 07:09 jiangchao123

好像不行 会报错 jwt.jks放在resources下

java.lang.IllegalStateException: Cannot load keys from store: class path resource [jwt.jks]

我看几个类似的项目都把这种方式屏蔽了

junneyang avatar Sep 06 '17 07:09 junneyang

抱歉,我发现这几个项目,之前由于我配了一个全局的ignore文件,导致配置文件都没有提交上去,现在再试一下~

jiangchao123 avatar Sep 06 '17 10:09 jiangchao123