Skip to content

Commit 1dffc22

Browse files
authored
Merge pull request #13 from Ironirc/master
Ability to check jwt against RSA PUBLIC KEY (PEM)
2 parents d71e016 + 52efaf9 commit 1dffc22

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

source/JSONWebToken-OpenSSL.package/JWARSASHA256.class/class/checkSignature.withKey..st

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ checkSignature: parts withKey: key
77
parts second}.
88
signatureByteArray := parts third base64Padded base64Decoded
99
asByteArray.
10-
rsa := LcRSA fromPemString: key.
10+
rsa := (key includesSubstring: 'BEGIN RSA PUBLIC KEY')
11+
ifTrue: [ LcRSA fromRsaPublicKeyPemString: key ]
12+
ifFalse: [ LcRSA fromPemString: key ].
1113
pubKey := LcEvpPublicKey setRSA: rsa.
12-
13-
(pubKey
14-
digestVerifyMessage: jwtHeaderAndPayload
15-
with: signatureByteArray) ifFalse: [ Error signal: 'signature does not match' ]
14+
(pubKey
15+
digestVerifyMessage: jwtHeaderAndPayload
16+
with: signatureByteArray)
17+
ifFalse: [ Error signal: 'signature does not match' ]

0 commit comments

Comments
 (0)