mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-03-11 09:12:01 +00:00
fix: support pkix public keys in oidc
This commit is contained in:
@@ -204,11 +204,22 @@ func (service *OIDCService) Init() error {
|
|||||||
if block == nil {
|
if block == nil {
|
||||||
return errors.New("failed to decode public key")
|
return errors.New("failed to decode public key")
|
||||||
}
|
}
|
||||||
publicKey, err := x509.ParsePKCS1PublicKey(block.Bytes)
|
switch block.Type {
|
||||||
if err != nil {
|
case "RSA PRIVATE KEY":
|
||||||
return err
|
publicKey, err := x509.ParsePKCS1PublicKey(block.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
service.publicKey = publicKey
|
||||||
|
case "PUBLIC KEY":
|
||||||
|
publicKey, err := x509.ParsePKIXPublicKey(block.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
service.publicKey = publicKey.(crypto.PublicKey)
|
||||||
|
default:
|
||||||
|
return errors.New("unsupported public key type")
|
||||||
}
|
}
|
||||||
service.publicKey = publicKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We will reorganize the client into a map with the client ID as the key
|
// We will reorganize the client into a map with the client ID as the key
|
||||||
|
|||||||
Reference in New Issue
Block a user