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

[REVIEW] Implement filestore backend for certificate groups #6479

Merged
merged 6 commits into from
Jun 4, 2024

Conversation

NoelGraf
Copy link
Member

No description provided.

@NoelGraf NoelGraf force-pushed the feat_gds_file_store branch 3 times, most recently from 871bc03 to 4d5ff96 Compare May 15, 2024 11:31
@mcpat
Copy link
Contributor

mcpat commented May 15, 2024

Hi Noel,
if I understand this PR correctly, the filestore backend cannot be explicitly disabled at the moment. Is a feature flag (via CMake) planned so far?

if(!certBio)
return UA_STATUSCODE_BADINTERNALERROR;

X509 *cert = PEM_read_bio_X509(certBio, NULL, 0, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks rather restrictive. Why not allowing DER here too (like MbedTLS nicely does for us).

UA_String trustedCrlFolder;
UA_String issuerCertFolder;
UA_String issuerCrlFolder;
UA_String rejectedCertFolder;
Copy link
Contributor

Choose a reason for hiding this comment

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

Persistence of rejected certificates is mainly a nice-to-have because it is not required by the spec. Nevertheless I just wanted to ask, if there are any limits applied on how many rejected certificates are kept?

CMakeLists.txt Outdated
@@ -1073,6 +1073,10 @@ list(APPEND plugin_sources
${PROJECT_SOURCE_DIR}/plugins/crypto/openssl/ua_certificategroup_memorystore_openssl.c)
endif()

if(UA_ENABLE_ENCRYPTION_MBEDTLS OR UA_ENABLE_ENCRYPTION_OPENSSL OR UA_ENABLE_ENCRYPTION_LIBRESSL OR UA_ENABLE_AMALGAMATION)
Copy link
Member

Choose a reason for hiding this comment

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

UA_ENABLE_ENCRYPTION could be enough to test.

@NoelGraf
Copy link
Member Author

Hi Marcel,
We do not currently plan to add a CMake flag, as we aim to avoid increasing the number of flags.

@mcpat
Copy link
Contributor

mcpat commented May 24, 2024

Hi Noel,
so the filestore backend will automatically be disabled if the target platform is neither POSIX nor Windows then? This is usually the case when building the open62541 stack for embedded platforms.

@NoelGraf NoelGraf force-pushed the feat_gds_file_store branch 2 times, most recently from 6156aaf to 8dbfa41 Compare May 29, 2024 08:30
@NoelGraf NoelGraf changed the title [WIP] Implement filestore backend for certificate groups [REVIEW] Implement filestore backend for certificate groups May 29, 2024
@NoelGraf NoelGraf force-pushed the feat_gds_file_store branch 3 times, most recently from 148a6ab to fb57d66 Compare May 29, 2024 13:54
Copy link
Member

@jpfr jpfr 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! Comments inline.

include/open62541/util.h Show resolved Hide resolved
return 0;
}

char* tmp_dir = copyStr(dir);
Copy link
Member

Choose a reason for hiding this comment

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

copyStr is not needed.
It uses strlen internally - so the input to copyStr is already null-terminated.

The entire code is strange. mkpath calls itself recursively???

/* Read files from directory */
size_t numActCerts = 0;
dir = opendir(listPath);
if(dir) {
Copy link
Member

Choose a reason for hiding this comment

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

You can reset dir with rewinddir.
That cannot fail.

if(dir) {
struct dirent *dirent;
while((dirent = readdir(dir)) != NULL) {
if(dirent->d_type == DT_REG) {
Copy link
Member

Choose a reason for hiding this comment

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

Use continue to skip instead of nested ifs.

/* Check parameter */
if (certGroup == NULL || trustList == NULL) {
return UA_STATUSCODE_BADINTERNALERROR;
}
Copy link
Member

Choose a reason for hiding this comment

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

Dont add { } guards for a single instruction-line after an if.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not? It seems to be a bad habbit of not doing it and results in cleaner (here: unambiguous) code?

static void
FileCertStore_clear(UA_CertificateGroup *certGroup) {
/* check parameter */
if (certGroup == NULL) {
Copy link
Member

Choose a reason for hiding this comment

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

Do it as this:

if(!certGroup || !certGroup->context)
    return;

Then you also don't need the if-clause below.

@jpfr jpfr merged commit d42454e into open62541:master Jun 4, 2024
66 checks passed
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.

None yet

3 participants