riboseinc / digicert

Ruby bindings for the Digicert Services API
https://www.digicert.com/services/v2/documentation
MIT License
8 stars 10 forks source link

Fix duplicate certificate finder bug #138

Closed abunashir closed 6 years ago

abunashir commented 6 years ago

To find a duplicate certificate, we are using retrieving details for any requests and then use the created_at date for the request and order to find out the duplicate order.

But for some reason, looks like there might be couple of seconds or differences between those dates, so this commit changes our finder to look for any certificate with 5 seconds time and this should fix the issue for now.

In the future, we should look for more stable solution, and if necessary then we can also adjust the time.

Fixes #137

ronaldtse commented 6 years ago

@abunashir thank you for this! Appreciate it đź‘Ť

kwkwan commented 6 years ago

The certificate should return error if the request is still pending.

Digicert::DuplicateCertificateFinder.find_by(request_id: request_id)

Currently, a certificate can be returned even if the request is pending. The date_created of certificate is not matched with the date of the request.

Here is the certificate request:

#<Digicert::ResponseObject id=11111, date="2018-04-20T06:00:53+00:00", type="duplicate", status="pending",....

and the certificate is:

#<Digicert::ResponseObject id=22222, thumbprint="xxxxx", serial_number="yyyyy", common_name="www.myhost.com", dns_names=["www.myhost.com", "myhost.com"], status="approved", date_created="2018-04-17T02:05:42+00:00", ...
abunashir commented 6 years ago

Hi @kwkwan, sorry I've overlooked this comment. I'm not sure if I understand correctly, but do you want to verify/filter the certificate that is approved before returning antyhing from this endpoint otherwise raise an error?

This is the digicert exact response for pending certificate, and won't it be better to keep it like that and add customize behvabhour on the actual application, so we don't lose the the data from this endpoint and user can use as it fits their needs?

ronaldtse commented 6 years ago

Hi @abunashir! The issue we had was to fetch the corresponding “issued” certificate. Currently, it returns an “issued” certificate but is not corresponding to the provided request’s date and time.

abunashir commented 6 years ago

Ah okay, @ronaldtse: I've been trying to reproduce this issue but I couldn't do it, can you guys provide me some information on how I might be able to reproduce this issue?

ronaldtse commented 6 years ago

@abunashir Skype me and I'll explain. Thanks!

abunashir commented 6 years ago

@kwkwan: Sorry my bad, I overlooked some stuff earlier, but thanks to @ronaldtse for explaining the issue. Could you guys please have a look at #144 and see if that would work for now?