简体   繁体   English

如何获得jhipster jwt私钥?

[英]how to get jhipster jwt private key?

I am creating multiple microservice applications with jhipster. 我正在用jhipster创建多个微服务应用程序。 I am using UAA server for authentication and tasks related to users. 我正在使用UAA服务器进行身份验证和与用户相关的任务。 I need to manipulate the JWT that jhipster creates and add a few properties to the payload, but I cannot seem to find how to get jhipster's private key. 我需要操纵jhipster创建的JWT并向有效负载中添加一些属性,但是我似乎找不到如何获取jhipster私钥的方法。

jHipster is signing the jwt with rs256 algorithm. jHipster正在使用rs256算法对jwt进行签名。 I have accessed the jwt and altered the payload, but I cannot sign it with the rs256 algorithm because I don't how to retrieve it. 我已经访问了jwt并更改了有效负载,但是我无法使用rs256算法对其进行签名,因为我不知道如何检索它。 I tried to switch to symmetric algorithms but then I could not verify the token because the verifier works with rs256 algorithm. 我尝试切换到对称算法,但由于验证程序与rs256算法一起使用,因此无法验证令牌。

ResponseEntity<OAuth2AccessToken> responseEntity = restTemplate.postForEntity(getTokenEndpoint(), entity, OAuth2AccessToken.class);

jhipster is using this code to authenticate and return a token. jhipster正在使用此代码进行身份验证并返回令牌。 I am trying to create a new token with: 我正在尝试使用以下方法创建新令牌:

JwtBuilder token = Jwts.builder()
            .setHeader(headerMap)
            .setClaims((Map<String, Object>) jwtMap.get("payload"))
            .signWith(SignatureAlgorithm.RS256, privateKey);
        String newJwt = token.compact();

but I do not have the private key. 但我没有私钥。

I tried to generate a new private key and work with it but I got Caused by: org.springframework.security.jwt.crypto.sign.InvalidSignatureException: RSA Signature did not match content error. 我试图生成一个新的私钥并对其进行处理,但得到的Caused by: org.springframework.security.jwt.crypto.sign.InvalidSignatureException: RSA Signature did not match content错误Caused by: org.springframework.security.jwt.crypto.sign.InvalidSignatureException: RSA Signature did not match content I want to change the jwt payload and add properties to it and use the new token as the access token for jhipster authentication. 我想更改jwt有效负载并为其添加属性,并将新令牌用作jhipster身份验证的访问令牌。

thanks in advance 提前致谢

It's in the keystore generated using java keytool. 它在使用java keytool生成的密钥库中。

The command to use is described in comments of application-prod.yml in your generated uaa project. 生成的uaa项目中application-prod.yml注释中描述了要使用的命令。

keytool -genkey -alias uaa -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM