# Would it be possible to sign a jwt token with a RSA public key?

**URL:** <https://community.auth0.com/t/would-it-be-possible-to-sign-a-jwt-token-with-a-rsa-public-key/80978>\
**Category:** JWT.io\
**Tags:** spring-boot\
**Created:** [April 1, 2022, 6:44pm UTC](https://community.auth0.com/t/would-it-be-possible-to-sign-a-jwt-token-with-a-rsa-public-key/80978 "2022-04-01T18:44:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cvfelipeoliveira](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cvfelipeoliveira/32/36336_2.png) [@cvfelipeoliveira](https://community.auth0.com/u/cvfelipeoliveira)\
**Post date:** [April 1, 2022, 6:44pm UTC](https://community.auth0.com/t/would-it-be-possible-to-sign-a-jwt-token-with-a-rsa-public-key/80978/1 "2022-04-01T18:44:49Z")

</div>

I can sign the token with the private key. see the code below. I would like to change it and make it sign with the public key.

```auto
return Jwts.builder()
.setExpiration(from(now().plusDays(EXP_DAYS).atZone(ZONE_ID).toInstant()))
.setIssuedAt(from(now().atZone(ZONE_ID).toInstant()))
.setAudience(input.getAud())
.setIssuer(input.getIss())
.setNotBefore(from(now().atZone(ZONE_ID).toInstant()))
.setHeaderParams(headers)
.addClaims(claims)
.signWith(RS256, this.jwtKeyPrivateProvider.getPrivateKey())
.compact();

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 4, 2022, 4:31pm UTC](https://community.auth0.com/t/would-it-be-possible-to-sign-a-jwt-token-with-a-rsa-public-key/80978/3 "2022-04-04T16:31:30Z")

</div>

Hi @cvfelipeoliveira,

Welcome to the Auth0 Community!

Not really…technically you could use the public key to make a signed JWT, but it wont work the same way as a JWT signed with the private key. Can you explain why you want to do this?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 22, 2022, 12:04am UTC](https://community.auth0.com/t/would-it-be-possible-to-sign-a-jwt-token-with-a-rsa-public-key/80978/4 "2022-04-22T00:04:31Z")

</div>


