fix leaking certificate issue (#265)

* fix leaking certificate issue

* mypy

* mypy ignore
1 file changed