mirror of https://github.com/golang-jwt/jwt.git
gofmt
This commit is contained in:
parent
57235a88e6
commit
295a7342f2
10
rs256.go
10
rs256.go
|
@ -30,17 +30,17 @@ func (m *SigningMethodRS256) Verify(signingString, signature string, key []byte)
|
||||||
if block, _ = pem.Decode(key); block != nil {
|
if block, _ = pem.Decode(key); block != nil {
|
||||||
var parsedKey interface{}
|
var parsedKey interface{}
|
||||||
if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
|
if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
|
||||||
parsedKey, err = x509.ParseCertificate(block.Bytes)
|
parsedKey, err = x509.ParseCertificate(block.Bytes)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if rsaKey, ok := parsedKey.(*rsa.PublicKey); ok {
|
if rsaKey, ok := parsedKey.(*rsa.PublicKey); ok {
|
||||||
hasher := sha256.New()
|
hasher := sha256.New()
|
||||||
hasher.Write([]byte(signingString))
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
err = rsa.VerifyPKCS1v15(rsaKey, crypto.SHA256, hasher.Sum(nil), sig)
|
err = rsa.VerifyPKCS1v15(rsaKey, crypto.SHA256, hasher.Sum(nil), sig)
|
||||||
} else if cert, ok := parsedKey.(*x509.Certificate); ok {
|
} else if cert, ok := parsedKey.(*x509.Certificate); ok {
|
||||||
err = cert.CheckSignature(x509.SHA256WithRSA, []byte(signingString), sig)
|
err = cert.CheckSignature(x509.SHA256WithRSA, []byte(signingString), sig)
|
||||||
} else {
|
} else {
|
||||||
err = errors.New("Key is not a valid RSA public key")
|
err = errors.New("Key is not a valid RSA public key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue