-
Notifications
You must be signed in to change notification settings - Fork 4
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
make certificate verification work for self-signed certificate #29
make certificate verification work for self-signed certificate #29
Conversation
Signed-off-by: William Xiang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add new tests for this?
src/sqlJob.ts
Outdated
// So the certificate verification cannot pass, should set rejectUnauthorized to false. | ||
let rejectUnauthorized = true; | ||
|
||
if (db2Server.ca) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we pass in the db2server.ca into the function, shouldn't the server get verified based on if it has that certificate? I'm not sure why rejectUnauthorized is not just True
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally it should use that specified CA certificate to verify the server's certificate. But in scenario that server does not use a self-signed certificate and is not configured properly to send the full chain certificate during the handshake, the db2server.ca is just the server certificate. Since this certificate is not a self-signed, it cannot be verified by itself. That's the reason why rejectUnauthorized needs to be false for this scenario.
We can keep using existing test cases unless we want to use the designated machines to test the getRootCerttificate part. |
I don't think we have any tests that the client will not connect if the certificate is invalid |
The changes in this PR make sure it can get the correct content of certificate and trust it for secure connection.
The main change is trying to use certificate verification during TLS handshake as much as possible. There are four scenarios: