Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft for adding insecure certificates option #68

Merged
merged 21 commits into from
Aug 26, 2022

Conversation

Techno-Fox
Copy link
Contributor

The linux and windows are working, however I'm having issues with the macos side of things. I don't have much experience with macos, so please forgive my ignorance. I look forward to discussing this with you. Also. Sorry if my replies seem a little late. Work can be long.

added the insecure option to the type Request
added the insecure option to the newRequest function, by default it is false (meaning secure)
is the option for insecure is set, then the insecure options for curl or set. That being to disable peer, and host verification.
added flags for setting insecure options, and an error for secure failure.
added the error to check for a resend request., because sometimes Negotiate authorization handshakes may return this error
added the WinHttpSetOption function from the dynamic library winhttp. This will allow us the set security options on the request.
Added the WINHTTP_OPTION_SECURITY_FLAGS for setting security options, and the ERROR_INTERNET_INVALID_CA error, for catching another security error
This implementation allows for insecure connection if specified. This required adding some more definitions, and procedures to windefs.nim
adding the setAllowsAnyHTTPSCerfiticate function.
@treeform
Copy link
Owner

This is missing tests. Is it possible to create a debug test server with a self signed cert?

@Techno-Fox
Copy link
Contributor Author

I've made a test server yes. I didn't add the tests, because I didn't know if you would want that or not. But yes. I can provide the tests. It might take a while though. Getting ready for work.

This python server utilizes self signed certificates for HTTPS communication for testing the insecure ssl PR draft.
added self signed certificates utilizing openSSL.
@Techno-Fox
Copy link
Contributor Author

I've added a test block "insecure" to tests.nim

I've also added test server in python

and I've also added self signed certificates utilizing openSSL.

I've forgot to remove some variables for testing when making the test server.
@Techno-Fox
Copy link
Contributor Author

Techno-Fox commented Feb 23, 2022

So I've tried both of your recommendations. with setAllowsAnyHTTPSCertificate, however I still get the error attached as a screenshot.

image

@treeform
Copy link
Owner

Yeah setAllowsAnyHTTPSCertificate is a private API so apple can and probably just removed it or it might have different arguments now. We need to find an official way to do this that is documented by Apple.

@Techno-Fox
Copy link
Contributor Author

So, if my research is correct. Apple API doesn't allow self signed certificates (Not without the private api).

@guzba
Copy link
Collaborator

guzba commented Aug 9, 2022

@Techno-Fox If you're still interested in this PR and would like your version merged, consider #79 as some feedback (no loop on Windows, smaller Python server, more clear name since insecure would need docs saying allow any https certificate so mind as well just call the flag that.

I'm sure @treeform will have opinions too and you're welcome to share your thoughts. Just trying to save a bunch of back and forth. Not trying to steal your PR commit if you would like that accomplishment.

@Techno-Fox
Copy link
Contributor Author

Yes actually. I would still be interested in merging. Thank you for just not stealing. Accomplishments are always welcome.

@Techno-Fox
Copy link
Contributor Author

It's been a while. Mind catching me up on what's happening with the PR?

@Techno-Fox
Copy link
Contributor Author

If I remember correctly. During testing it didn't work without the loop on Windows. Unless someone has found a way to do so.

@Techno-Fox
Copy link
Contributor Author

I thought I did make the variable name to allowAnyHttpsCertificate?

@Techno-Fox
Copy link
Contributor Author

And how small do you want the python server?

@guzba
Copy link
Collaborator

guzba commented Aug 9, 2022

I thought I did make the variable name to allowAnyHttpsCertificate?

It is still insecure for this PR.

insecure*: bool

@guzba
Copy link
Collaborator

guzba commented Aug 9, 2022

If I remember correctly. During testing it didn't work without the loop on Windows. Unless someone has found a way to do so.

A loop is not needed, just a second call to WinHttpSendRequest, see https://github.com/treeform/puppy/pull/79/files#diff-1ebf7a29255776895f8c7e956c2c1a4ffa73ceec647a3723a5c75e0712a253ff

Note I want to ignore the retry error, unless we can reproduce and test it. It is not needed in my testing for self-signed certs.

@guzba
Copy link
Collaborator

guzba commented Aug 9, 2022

And how small do you want the python server?

The server in this PR includes some big ###### comments that don't add anything to such a small test file. I'd like to just have the simple Python. That's probably the only thing I'd prefer changed.

@guzba
Copy link
Collaborator

guzba commented Aug 9, 2022

Yes actually. I would still be interested in merging. Thank you for just not stealing. Accomplishments are always welcome.

No problem, we'll get this merged soon here with just a few tweaks.

@Techno-Fox
Copy link
Contributor Author

K. Thanks for letting me know what's needed. I'm just getting off work, so I'll see about fixing these possibly tomorrow (my time at least)

@guzba
Copy link
Collaborator

guzba commented Aug 9, 2022

K. Thanks for letting me know what's needed. I'm just getting off work, so I'll see about fixing these possibly tomorrow (my time at least)

Sounds good!

Techno-Fox and others added 4 commits August 10, 2022 08:10
Thank you @guzba for giving great ideas to add to this PR, I've added a smaller test server, updated the variable name, and thanks again @guzba for showing me how to use https without a loop for windows.
messed up on commit pull, this might fix confilcts
Been a while working on this repository, hopefully this fixes an conflicts.
@Techno-Fox
Copy link
Contributor Author

sorry that took so many tries, made a python script that could look at the diffs of each commit, and well it was an old script, so I had to fix some bugs.

@Techno-Fox
Copy link
Contributor Author

Let me know if I've forgot anything

Copy link
Collaborator

@guzba guzba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR. Added some notes that'll get us very close to merge ready.

src/puppy/common.nim Outdated Show resolved Hide resolved
src/puppy/platforms/macos/macdefs.nim Outdated Show resolved Hide resolved
src/puppy/platforms/macos/platform.nim Outdated Show resolved Hide resolved
src/puppy/platforms/win32/platform.nim Outdated Show resolved Hide resolved
src/puppy/platforms/win32/windefs.nim Outdated Show resolved Hide resolved
tests/test.nim Outdated Show resolved Hide resolved
src/puppy.nim Outdated Show resolved Hide resolved
@Techno-Fox
Copy link
Contributor Author

alright, I'll get on it

Alright somethings I'll have to fix in my script, but I went back and edited them manually. Please let me know if I've forgotten anything.
@@ -79,22 +86,22 @@ proc WinHttpConnect*(
): HINTERNET {.dynlib: "winhttp".}

proc WinHttpOpenRequest*(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things look close to passing tests, close to done here which is gerat. I think the remaining issue is that WinHttpOpenRequest needs the full correct function parameters back (they're deleted currently in the PR).

See https://github.com/treeform/puppy/runs/7845915480?check_suite_focus=true

I've added the function parameters requested, must've forgotten about them during manual editing.
@Techno-Fox
Copy link
Contributor Author

I've added the function parameters

@@ -118,6 +118,44 @@ proc fetch*(req: Request): Response {.raises: [PuppyError].} =
PuppyError, "WinHttpSendRequest error: " & $GetLastError()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're checking error and possibly retrying, we do not want to raise an exception yet. This should be removed to get windows passing the tests (https://github.com/treeform/puppy/runs/7869416921?check_suite_focus=true)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is probably fix needed to get things ready to merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright I'll remove it.

Removed the exception at the line specified to remove at.
@Techno-Fox
Copy link
Contributor Author

sorry for the wait. Had work.

@treeform treeform merged commit 0016aae into treeform:master Aug 26, 2022
@treeform
Copy link
Owner

Thank you for this PR. Its a big one. We appreciate you working with us to get it in.

Congrats!

@Techno-Fox
Copy link
Contributor Author

Welcome.

@guzba guzba mentioned this pull request Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants