@@ -161,6 +161,7 @@ func (service *OIDCService) Init() error {
161161 Type : "RSA PRIVATE KEY" ,
162162 Bytes : der ,
163163 })
164+ tlog .App .Trace ().Str ("type" , "RSA PRIVATE KEY" ).Msg ("Generated private RSA key" )
164165 err = os .WriteFile (service .config .PrivateKeyPath , encoded , 0600 )
165166 if err != nil {
166167 return err
@@ -171,6 +172,7 @@ func (service *OIDCService) Init() error {
171172 if block == nil {
172173 return errors .New ("failed to decode private key" )
173174 }
175+ tlog .App .Trace ().Str ("type" , block .Type ).Msg ("Loaded private key" )
174176 privateKey , err = x509 .ParsePKCS1PrivateKey (block .Bytes )
175177 if err != nil {
176178 return err
@@ -194,6 +196,7 @@ func (service *OIDCService) Init() error {
194196 Type : "RSA PUBLIC KEY" ,
195197 Bytes : der ,
196198 })
199+ tlog .App .Trace ().Str ("type" , "RSA PUBLIC KEY" ).Msg ("Generated public RSA key" )
197200 err = os .WriteFile (service .config .PublicKeyPath , encoded , 0644 )
198201 if err != nil {
199202 return err
@@ -204,8 +207,9 @@ func (service *OIDCService) Init() error {
204207 if block == nil {
205208 return errors .New ("failed to decode public key" )
206209 }
210+ tlog .App .Trace ().Str ("type" , block .Type ).Msg ("Loaded public key" )
207211 switch block .Type {
208- case "RSA PRIVATE KEY" :
212+ case "RSA PUBLIC KEY" :
209213 publicKey , err := x509 .ParsePKCS1PublicKey (block .Bytes )
210214 if err != nil {
211215 return err
@@ -218,7 +222,7 @@ func (service *OIDCService) Init() error {
218222 }
219223 service .publicKey = publicKey .(crypto.PublicKey )
220224 default :
221- return errors . New ("unsupported public key type" )
225+ return fmt . Errorf ("unsupported public key type: %s" , block . Type )
222226 }
223227 }
224228
0 commit comments