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

feat: Enable TLS 1.3 with mutual auth (AB:2378) #115

Merged
merged 5 commits into from
Aug 26, 2022
Merged

Conversation

shalinnijel2
Copy link
Contributor

Summary of changes:

  • Updated create_certs.sh to generate oemCertChain.pem
  • Added a new env variable ENABLE_TLS_1_3 - False by default
  • Updated get_ssl_context() for server to check client cert chain and client to offer cert chain if TLS 1.3 is enabled
  • Updated README.
  • Updated .env.dev.local and .env.dev.docker to include ENABLE_TLS_1_3 variable.

@shalinnijel2 shalinnijel2 requested a review from tropxy August 24, 2022 16:34
if ENABLE_TLS_1_3:
ssl_context = ssl.create_default_context(
purpose=Purpose.CLIENT_AUTH if server_side else Purpose.SERVER_AUTH,
cafile=CertPath.OEM_ROOT_PEM if server_side else CertPath.V2G_ROOT_PEM,
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldnt it be:

cafile=CertPath.V2G_ROOT_PEM if server_side else CertPath.OEM_ROOT_PEM,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like caFile points to the certificate required to verify the peer's chain ...
https://docs.python.org/3/library/ssl.html#ssl.create_default_context

Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed, the create_default_context already does the same settings as later done in the code; instead we can do the following:

if ENABLE_TLS_1_3:
    ssl_context = SSLContext(protocol=ssl.PROTOCOL_TLS)
else:
    ssl_context = SSLContext(protocol=ssl.PROTOCOL_TLSv1_2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

ssl_context = SSLContext(protocol=PROTOCOL_TLSv1_2)

if ENABLE_TLS_1_3:
ssl_context = ssl.SSLContext()
Copy link
Contributor

Choose a reason for hiding this comment

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

creating the context without specifying the protocol is deprecated. select ssl.PROTOCOL_TLS instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops...changed now...

@shalinnijel2 shalinnijel2 requested a review from tropxy August 25, 2022 17:11
@shalinnijel2 shalinnijel2 merged commit 11fe796 into master Aug 26, 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.

2 participants