mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-16 20:48:37 -04:00
Fixed merge conflict
This commit is contained in:
@@ -2,10 +2,12 @@ import base64
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import oscrypto.asymmetric
|
||||
import oscrypto.errors
|
||||
import requests
|
||||
import six
|
||||
from cryptography import x509
|
||||
from cryptography.exceptions import InvalidSignature
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from cryptography.hazmat.primitives.asymmetric import padding
|
||||
|
||||
from app import redis_store
|
||||
from app.config import Config
|
||||
@@ -110,15 +112,16 @@ def validate_sns_cert(sns_payload):
|
||||
if isinstance(certificate, six.text_type):
|
||||
certificate = certificate.encode()
|
||||
|
||||
# load the certificate
|
||||
certificate = x509.load_pem_x509_certificate(certificate)
|
||||
|
||||
signature = base64.b64decode(sns_payload["Signature"])
|
||||
|
||||
try:
|
||||
oscrypto.asymmetric.rsa_pkcs1v15_verify(
|
||||
oscrypto.asymmetric.load_certificate(certificate),
|
||||
signature,
|
||||
string_to_sign,
|
||||
"sha1",
|
||||
public_key = certificate.public_key()
|
||||
public_key.verify(
|
||||
signature, string_to_sign, padding.PKCS1v15(), hashes.SHA256() # or SHA1?
|
||||
)
|
||||
return True
|
||||
except oscrypto.errors.SignatureError:
|
||||
except InvalidSignature:
|
||||
raise ValidationError("Invalid signature")
|
||||
|
||||
Reference in New Issue
Block a user