Signed webhook verification fails
envgap__sendgrid__sendgrid-python-1014
01 / FAILURE SIGNATURE
As reported upstream
AttributeError: 'NoneType' object has no attribute 'group'
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
0d00f0dfe98a8c442c66f891f6fca18234418606- Manifest
requirements.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
sendgrid/sendgrid-python #1014 · read the original issue
<!--
If this is a feature request, make sure you search Issues for an existing request before creating a new one!
Please utilize the template below to help us resolve your issue.
Note that many issues can be resolved by updating to the latest version.
-->
### Issue Summary
`EventWebhook.convert_public_key_to_ecdsa` doesn't seem to be compatible with the version 2.0.0 of [starkbank-ecdsa](https://github.com/starkbank/ecdsa-python) 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
```python
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
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]