Skip to content

Commit

Permalink
Merge pull request #84 from drighty/master
Browse files Browse the repository at this point in the history
more winhttp cert error to work with allowAnyHttpsCertificate
  • Loading branch information
treeform authored Dec 7, 2022
2 parents 6ca6804 + d79dd3b commit fb0aae3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/puppy/platforms/win32/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ proc fetch*(req: Request): Response {.raises: [PuppyError].} =
) == 0:

let error = GetLastError()
if error in {ERROR_WINHTTP_SECURE_FAILURE, ERROR_INTERNET_INVALID_CA} and
if error in {ERROR_WINHTTP_SECURE_FAILURE, ERROR_INTERNET_INVALID_CA, ERROR_INTERNET_SEC_CERT_DATE_INVALID, ERROR_INTERNET_SEC_INVALID_CERT, ERROR_INTERNET_SEC_CERT_CN_INVALID, ERROR_INTERNET_SEC_CERT_NO_REV, ERROR_INTERNET_SEC_CERT_REV_FAILED, ERROR_INTERNET_SEC_CERT_REVOKED, ERROR_INTERNET_SEC_CERT_ERRORS} and
req.allowAnyHttpsCertificate:
# If this is a certificate error but we should allow any HTTPS cert,
# we need to set some options and retry sending the request.
Expand Down
8 changes: 8 additions & 0 deletions src/puppy/platforms/win32/windefs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ const
ERROR_INSUFFICIENT_BUFFER* = 122
ERROR_WINHTTP_SECURE_FAILURE* = 12175
ERROR_INTERNET_INVALID_CA* = 12045
ERROR_INTERNET_SEC_CERT_DATE_INVALID* = 12037
ERROR_INTERNET_SEC_INVALID_CERT* = 12169
ERROR_INTERNET_SEC_CERT_ERRORS* = 12055
ERROR_INTERNET_SEC_CERT_NO_REV* = 12056
ERROR_INTERNET_SEC_CERT_CN_INVALID* = 12038
ERROR_INTERNET_SEC_CERT_REV_FAILED* = 12057
ERROR_INTERNET_SEC_CERT_REVOKED* = 12170

WINHTTP_OPTION_SECURITY_FLAGS* = 31
SECURITY_FLAG_IGNORE_UNKNOWN_CA* = 0x00000100
# SECURITY_FLAG_IGNORE_WRONG_USAGE* = 0x00000200
Expand Down

0 comments on commit fb0aae3

Please sign in to comment.