Skip to content

Signed webhook verification fails #1014

@simopot

Description

@simopot

Issue Summary

EventWebhook.convert_public_key_to_ecdsa doesn't seem to be compatible with the version 2.0.0 of starkbank-ecdsa released a couple of days ago. Installing the older starkbank-ecdsa==1.0.0 fixes the issue.

Steps to Reproduce

Call convert_public_key_to_ecdsa with a valid public key
or
Run tests in test/test_eventwebhook.py

Code Snippet

from sendgrid.helpers.eventwebhook import EventWebhook
PUBLIC_KEY = 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE83T4O/n84iotIvIW4mdBgQ/7dAfSmpqIM8kF9mN1flpVKS3GRqe62gw+2fNNRaINXvVpiglSI8eNEc6wEA3F+g=='
ew = EventWebhook()
ew.convert_public_key_to_ecdsa(PUBLIC_KEY)

Exception/Log

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xxx/sendgrid-python/sendgrid/helpers/eventwebhook/__init__.py", line 30, in convert_public_key_to_ecdsa
    return PublicKey.fromPem(public_key)
  File "/usr/local/lib/python3.9/site-packages/ellipticcurve/publicKey.py", line 39, in fromPem
    publicKeyPem = getPemContent(pem=string, template=_pemTemplate)
  File "/usr/local/lib/python3.9/site-packages/ellipticcurve/utils/pem.py", line 6, in getPemContent
    return search("".join(pattern.splitlines()), "".join(pem.splitlines())).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Technical details:

Tried with

  • sendgrid-python version: 6.8.2
  • python version: 3.9.5

and

  • sendgrid-python version: 6.7.1
  • python version: 3.6.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugbug in the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions