OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - PublicKey.txt 에 의한 검증(RSA)
KeyStore 클래스
Java는
KeyStore라는 인터페이스를 통해 암호화/복호화 및 전자 서명에 사용되는Private Key,Public Key와 Certificate 를 추상화하여 제공하고 있다.KeyStore에는 SecretKey, Private Key, Pbulic Key, Certificate 와 같은 보안 파일들이 저장되며KeyStore라는 파일 시스템에 저장하고 암호로 보호할 수 있다.KeyStore는 keytool을 사용해서 생성할 수 있으며 기본 타입은jks이다.
keytool
keytool은 자바에서 제공하는 유틸리티로KeyStore기반으로 인증서와 키를 관리할 수 있으며 JDK 에 포함되어 있다.C:\Program Files\Java\jdk-17\bin\keytool.exe
KeyStore 생성 후 Private Key, Public Key, Certificate 생성
Private Key 생성 :
keytool -genkeypair -alias apiKey -keyalg RSA -keypass "pass1234" -keystore apiKey.jks -storepass "pass1234"Public Key 생성 :
keytool -export -alias apiKey -keystore apiKey.jks -rfc -file trustServer.cerCertificate 생성 :
keytool -import -alias trustServer -file trustServer.cer -keystore publicKey.jks


RsaPublicKeySecuritySigner
SecuritySigner를 상속 받아RSA암호화 방식의 서명 및 토큰을 발행하는 클래스
SecuritySigner
SignatureConfig
RsaKeyExtractor
apiKey.jks로부터PrivateKey와PublicKey를 추출하고 파일에 저장하는 클래스
ApplicationRunner를 상속하여 스프링 부트가 초기화 될 때 실행할 메서드 생성
application.yml
OAuth2ResourceServerJwtConfiguration.JwtDecoderConfiguration

KeyValueCondition을 통해 설정 파일에public-key-location가 존재하면RSAPublicKey를 사용해JwtDecoder를 생성하는 초기화 과정을 거친다.
JwtAuthorizationRsaPublicKeyFilter
JwtAuthorizationFilter
SecurityConfig
이전 ↩️ - OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwtDecoder 에 의한 검증(RSA)
다음 ↪️ - OAuth 2.0 Resource Server MAC & RSA 토큰 검증 - JwkSetUri 에 의한 검증(RSA)
Last updated
