io.jsonwebtoken.security.SignatureException: Unavailable RSA Signature algorithm 'RSASSA-PSS'
Elshad1 opened this issue · 3 comments
Elshad1 commented
Hello!
I am trying to create a JWT but I am getting this error message
io.jsonwebtoken.security.SignatureException: Unavailable RSA Signature algorithm 'RSASSA-PSS'.
at io.jsonwebtoken.impl.crypto.SignatureProvider.createSignatureInstance(SignatureProvider.java:68)
at io.jsonwebtoken.impl.crypto.RsaProvider.createSignatureInstance(RsaProvider.java:69)
at io.jsonwebtoken.impl.crypto.RsaSigner.doSign(RsaSigner.java:53)
at io.jsonwebtoken.impl.crypto.RsaSigner.sign(RsaSigner.java:43)
at io.jsonwebtoken.impl.crypto.DefaultJwtSigner.sign(DefaultJwtSigner.java:59)
at io.jsonwebtoken.impl.DefaultJwtBuilder.compact(DefaultJwtBuilder.java:353)
Mу code:
private fun generateJwt(): String {
var privateKeyPem: PemObject? = null
PemReader(InputStreamReader(context.assets.open("private.pem"))).use { reader ->
privateKeyPem = reader.readPemObject()
}
val keyFactory = KeyFactory.getInstance("RSA")
val privateKey = keyFactory.generatePrivate(PKCS8EncodedKeySpec(privateKeyPem?.content))
val now = Instant.now()
return Jwts.builder()
.setHeaderParam("kid", KEY_ID)
.setIssuer(SERVICE_ACCOUNT_ID)
.setAudience(AUDIENCE)
.setIssuedAt(Date.from(now))
.setExpiration(Date.from(now.plusSeconds(360)))
.signWith(privateKey, SignatureAlgorithm.PS256)
.compact()
}
My dependencies:
api 'io.jsonwebtoken:jjwt-api:0.11.2'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2'
runtimeOnly('io.jsonwebtoken:jjwt-orgjson:0.11.2') {
exclude group: 'org.json', module: 'json' //provided by Android natively
}
api 'org.bouncycastle:bcprov-jdk15on:1.60'
lhazlewood commented
Do you have a sample project that we can run? What JDK were you using for this test?
stale commented
This issue has been automatically marked as stale due to inactivity for 60 or more days. It will be closed in 7 days if no further activity occurs.
stale commented
Closed due to inactivity.