Skip to content

Platform specific TLS/SSL configuration context #53

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

Merged

Conversation

Darsstar
Copy link
Contributor

The test were failing on Windows due to TLS/SSL not working.

Figuring out why, and how to make it work wasn't that easy, so I figured platform specific SslConfigurationContext are probably worth the effort of implementing.

I chose Posix as the non-windows prefix based on https://github.com/apache/qpid-proton/blob/main/c/src/ssl/PLATFORM_NOTES.md, I will hapily change it if desired.

I had to rip the Certificate Revocation List extension out of the server certificate since Windows does try to access http://crl-server:????/<snip> in order to verify the validity of the server certificate. (I don't remember the exact url.) I ripped it out the the client certificate before realizing the server certificate was being validated, not the client certificate. I didn't undo the client certificate changes.

Anyway, now that I can run the full test suite I'll look into the async API. Thanks for reading, have a good day!

PS. I checked the Allow edits and access to secrets by maintainers checkbox, feel free to push to my branch to your heart's content.

FriendlyName,
)

os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pycharm likes to set the working directory to tests, this sets it to the project root so it can find .ci/certs.

@@ -826,7 +826,7 @@ def __init__(self, mode: int) -> None:
def _check(self, err: int) -> int:
if err < 0:
exc = EXCEPTIONS.get(err, SSLException)
raise exc("SSL failure.")
raise exc("SSL failure.", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was worth its weight in gold during debugging.
https://github.com/apache/qpid-proton/blob/main/c/src/ssl/schannel.cpp#L1967 resulting in an qpid protonTimeout instance is misleading. But at least the string mentions SSL.

@@ -80,17 +100,47 @@ def dial(self) -> None:
logger.debug("Enabling SSL")

self._ssl_domain = SSLDomain(SSLDomain.MODE_CLIENT)
if self._ssl_domain is not None:
self._ssl_domain.set_trusted_ca_db(self._conf_ssl_context.ca_cert)
assert self._ssl_domain
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why mypy needs this assert in order to assume it can't be None given that it is initialized to an instance of SSLDomain above, or never reaching this line due to the constructor raising an exception. But is does :(

def ssl_context(pytestconfig):
if sys.platform == "win32":
return WinSslConfigurationContext(
ca_store=PKCS12Store(path=".ci/certs/ca.p12"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did test CurrentUserStore("Personal") locally

@DanielePalaia
Copy link
Contributor

HI @Darsstar thanks a lot for your contribution! It is really appreciated, I'll have a look in the next days!

@DanielePalaia
Copy link
Contributor

Hi @Darsstar I tested both on Linux and Windows and it looks good.

Also the code looks good!

I'd suggest to create an example for windows too before merging!

Thanks!

@Darsstar
Copy link
Contributor Author

I'd suggest to create an example for windows too before merging!

Done

Copy link
Contributor

@DanielePalaia DanielePalaia left a comment

Choose a reason for hiding this comment

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

Looks good to me! Many thanks for the nice work.

@Gsantomaggio if for you is fine too I'm going to merge it

@Gsantomaggio
Copy link
Member

Gsantomaggio commented Feb 28, 2025

@Darsstar Darsstar force-pushed the platform-specific-SslConfigurationContext branch 2 times, most recently from 58c1699 to 92bfa64 Compare February 28, 2025 15:16
@Darsstar
Copy link
Contributor Author

oops, fixed.

@Darsstar Darsstar force-pushed the platform-specific-SslConfigurationContext branch from 92bfa64 to 0c7f845 Compare February 28, 2025 15:20
@DanielePalaia DanielePalaia merged commit d4ed42d into rabbitmq:main Feb 28, 2025
1 check passed
@Darsstar Darsstar deleted the platform-specific-SslConfigurationContext branch March 2, 2025 12:44
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