본문 바로가기

개발과정 간단 정리

JWT verify 할 때 생긴 에러 목록

0. jwt.io 에서는 비밀키 ,공개키 모두 넣어야지 검증이 된다.

1.PEM 수동으로 만드는법

KeyMaterial : HexString -(byte변환)-> KeyBinaray byte[] -(byte64로인코딩)-> PEM형식으로 변환 ( 앞뒤 헤더푸터붙이기)

 

 

1. PEM_read_bio_PUBKEY :  공개키 대신 String 을 넣은경우

Verify a RS256 jwt on node PEM_read_bio_PUBKEY failed

 

Verify a RS256 jwt on node PEM_read_bio_PUBKEY failed

I'm trying to I'm trying to verify a jwt that use the RS256 algorithm. When using the hs256 algorithm everything works fine let opts = { audience: 'y', issuer: `https://x.auth0.com/`, algor...

stackoverflow.com

 

RS256 needs a public key to verify, but you are providing an string

secretOrPublicKey is a string or buffer containing either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.

 

2.asn1 encoding routines:asn1_check_tlen:wrong tag

PKS1

헤더 푸터에 있는 BEGIN RSA PUBLIC KEY 에서 RSA를 빼고 아래처럼 바꿔준다.

 

-----BEGIN PUBLIC KEY-----
키 내용 

-----END PUBLIC KEY-----