From f5cd7ecbd5fcc2f68c35933f03ff5885c0cfb3a6 Mon Sep 17 00:00:00 2001 From: Hossein Shafagh Date: Fri, 15 Jan 2021 16:35:47 -0800 Subject: [PATCH 1/2] adding rate limit for Enturst --- lemur/certificates/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lemur/certificates/cli.py b/lemur/certificates/cli.py index 1f288c70..d78f267a 100644 --- a/lemur/certificates/cli.py +++ b/lemur/certificates/cli.py @@ -11,6 +11,7 @@ from flask_principal import Identity, identity_changed from flask_script import Manager from sqlalchemy import or_ from tabulate import tabulate +from time import sleep from lemur import database from lemur.authorities.models import Authority @@ -761,7 +762,10 @@ def deactivate_entrust_certificates(): certificates = get_all_valid_certs(['entrust-issuer']) entrust_plugin = plugins.get('entrust-issuer') - for cert in certificates: + for index, cert in enumerate(certificates, start=1): + if (index % 10) == 0: + # Entrust enforces a 10 request per 30s rate limit + sleep(30) try: response = entrust_plugin.deactivate_certificate(cert) if response == 200: From a62a562a61e597317bf1078645042c608aa3fe21 Mon Sep 17 00:00:00 2001 From: Hossein Shafagh Date: Fri, 15 Jan 2021 17:17:56 -0800 Subject: [PATCH 2/2] Update cli.py correct index begin --- lemur/certificates/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/certificates/cli.py b/lemur/certificates/cli.py index d78f267a..4b4b22e9 100644 --- a/lemur/certificates/cli.py +++ b/lemur/certificates/cli.py @@ -762,7 +762,7 @@ def deactivate_entrust_certificates(): certificates = get_all_valid_certs(['entrust-issuer']) entrust_plugin = plugins.get('entrust-issuer') - for index, cert in enumerate(certificates, start=1): + for index, cert in enumerate(certificates): if (index % 10) == 0: # Entrust enforces a 10 request per 30s rate limit sleep(30)