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

TLS support: pgagroal - PostgreSQL #70

Open
jesperpedersen opened this issue Apr 21, 2020 · 10 comments
Open

TLS support: pgagroal - PostgreSQL #70

jesperpedersen opened this issue Apr 21, 2020 · 10 comments
Assignees
Labels
community Issue that can be picked up by the community feature New feature

Comments

@jesperpedersen
Copy link
Collaborator

Support TLS v1.2 and TLS v1.3.

  • Extend the server structure with the required configuration parameters
  • Extend the connection structure with the SSL_SESSION data (i2d_SSL_SESSION())
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Apr 22, 2020
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Apr 24, 2020
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue May 6, 2020
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue May 15, 2020
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue May 18, 2020
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue May 22, 2020
@dpinchukov-ueni
Copy link

is there any hope of this getting merged into master?
i am playing around with pgagroal (1.1.0 release), and it looks like while the client->pgagroal connections can use TLS, the pgagroal->postgresql connections cannot.
support for this seems to be implemented in jesperpedersen@62b1424, but that branch is now rather outdated.

@jesperpedersen
Copy link
Collaborator Author

I'm working on something else at the momment, so community effort currently.

jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Oct 28, 2021
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Oct 28, 2021
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Nov 9, 2021
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Nov 16, 2021
jesperpedersen added a commit that referenced this issue Dec 2, 2021
Initial support for TLS connections to PostgreSQL, but
doesn't support pooling so we will keep the issue open until fixed
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Dec 13, 2021
Pooling support by saving the SSL session and reusing it
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Dec 14, 2021
Pooling support by saving the SSL session and reusing it
jesperpedersen added a commit to jesperpedersen/pgagroal that referenced this issue Dec 16, 2021
Pooling support by saving the SSL session and reusing it
@jesperpedersen
Copy link
Collaborator Author

#404 is related

@ashu3103
Copy link
Contributor

ashu3103 commented Aug 8, 2024

@jesperpedersen

Please assign me this issue.

@jesperpedersen jesperpedersen added feature New feature community Issue that can be picked up by the community labels Aug 8, 2024
@jesperpedersen
Copy link
Collaborator Author

@ashu3103 Have fun with it !

@ashu3103
Copy link
Contributor

@jesperpedersen

What is the issue with the current implementation, the worker is establishing tls for itself and supplies the ssl context to pipeline for ssl support in further connections.

Just for the part where use_pooled_connection (reusing a prefilled connection) are used there is no ssl.

@jesperpedersen
Copy link
Collaborator Author

@ashu3103 Yeah, we can connect to a TLS protected PostgreSQL instance, but the connections can't be cached since we can't currently serialize the SSLContext to be part of the pool.

You can investigate newer versions of OpenSSL, or look at alternative implmentations like

Create a test setup with self-signed certificates, create a connection, and return it to the pool. You will see it isn't cached.

This ties into requiring TLS certificates for connections - it is the easier part to start with

@ashu3103
Copy link
Contributor

ashu3103 commented Aug 24, 2024

@ashu3103 Yeah, we can connect to a TLS protected PostgreSQL instance, but the connections can't be cached since we can't currently serialize the SSLContext to be part of the pool.

But why are we not able to make SSLContext a part of the pool? Something like config->connections[ssl] = (SSL*)ssl_context

You can investigate newer versions of OpenSSL, or look at alternative implmentations like

Sure, but don't you think openssl has better community support and therefore rapid development

Create a test setup with self-signed certificates, create a connection, and return it to the pool. You will see it isn't cached.

This ties into requiring TLS certificates for connections - it is the easier part to start with

Okay!

@ashu3103
Copy link
Contributor

ashu3103 commented Aug 24, 2024

@ashu3103 Yeah, we can connect to a TLS protected PostgreSQL instance, but the connections can't be cached since we can't currently serialize the SSLContext to be part of the pool.

But why are we not able to make SSLContext a part of the pool? Something like config->connections[ssl] = (SSL*)ssl_context

In _prefill_auth we can do a ssl handshake after _get_connection and save in pool

You can investigate newer versions of OpenSSL, or look at alternative implmentations like

Sure, but don't you think openssl has better community support and therefore rapid development

Create a test setup with self-signed certificates, create a connection, and return it to the pool. You will see it isn't cached.
This ties into requiring TLS certificates for connections - it is the easier part to start with

Okay!

Also in _return_connection is there a specific reason which ssl has to NULL for the connection to be cached

if (config->connections[slot].has_security != SECURITY_INVALID &&
       (config->connections[slot].has_security != SECURITY_SCRAM256 ||
        (config->connections[slot].has_security == SECURITY_SCRAM256 &&
         (config->authquery || pgagroal_user_known(config->connections[slot].username)))) &&
       ssl == NULL)
   {

@jesperpedersen
Copy link
Collaborator Author

We have to reserve the slot in the pool - even for a SSL based connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Issue that can be picked up by the community feature New feature
Projects
None yet
Development

No branches or pull requests

3 participants