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

Add per replication agreement certificate settings #6021

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

minfrin
Copy link
Contributor

@minfrin minfrin commented Dec 31, 2023

Allow TLS certificates to be configured individually on replication agreements.

Add nsDS5ReplicaTransportUri, nsDS5ReplicaTransportCAUri, nsDS5ReplicaBootstrapTransportUri and nsDS5ReplicaBootstrapTransportCAUri to allow the URIs of certificates, keys and ca certificates to be specified for each agreement.

Based on OpenSSL provider support added to openldap here:

https://bugs.openldap.org/show_bug.cgi?id=10149
openldap/openldap#11

Allow TLS certificates to be configured individually on replication
agreements.

Add nsDS5ReplicaTransportUri, nsDS5ReplicaTransportCAUri,
nsDS5ReplicaBootstrapTransportUri and nsDS5ReplicaBootstrapTransportCAUri
to allow the URIs of certificates, keys and ca certificates to be
specified for each agreement.

Based on OpenSSL provider support added to openldap here:

https://bugs.openldap.org/show_bug.cgi?id=10149
openldap/openldap#11
if (0 == slapi_entry_attr_find(e,
bootstrap ? type_nsds5ReplicaBootstrapTransportCAUri : type_nsds5ReplicaTransportCAUri, &attr)) {

int i;
Copy link
Contributor

Choose a reason for hiding this comment

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

size_t, declare in the for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

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 has been made so.

Copy link
Contributor

@mreynolds389 mreynolds389 Jan 12, 2025

Choose a reason for hiding this comment

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

It's still an "int" Please change to "size_t" inside the "for" loop:

for (size_t i = slapi_attr_first_value .......)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

size_t creates a nasty bug - size_t is unsigned, but slapi_attr_next_value() indicates no-more-values by returning -1.

This created an infinite loop that ate all the ram.

slapi_attr_first_value() / slapi_attr_next_value() return signed results, so at the very least it must be ssize_t for all loops, not just this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh, I see. Ok, please ignore my comment :-)

/* We've got an ld. Now bind to the server. */

/* if we have TLS uris, set them now */
#ifdef LDAP_OPT_X_TLS_URIS
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm looking at the openldap source and I can't find a reference to this. Can you cite the docs about this flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The flag is based on OpenSSL provider support added to openldap here:

https://bugs.openldap.org/show_bug.cgi?id=10149
openldap/openldap#11

#endif

/* if we have TLS CA uris, set them now */
#ifdef LDAP_OPT_X_TLS_CACERTURIS
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with this flag.

}
/* if set, cacerturis takes precedence */
#ifdef LDAP_OPT_X_TLS_CACERTURIS
ldap_get_option(ld, LDAP_OPT_X_TLS_CACERTURIS, &cauris);
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point, is it possible that LDAP_OPT_X_TLS_CACERTURIS is set ?
IIUC setup_ol_tls_conn is called before LDAP_OPT_X_TLS_CACERTURIS is set (in conn_connect_with_bootstrap)

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 working by accident I think, it was't set on the first pass - thanks for catching this.

Fixed below.

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.

4 participants