From 7a5449f4e48d7304d4c717399a939648b9ba4fa4 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 15 Jul 2025 14:04:29 +0100 Subject: [PATCH] Avoid small behaviour change in #550 Motivation: In #550 a use of `NIOSSLCertificafe(file:format:)` was replaced with `NIOSSLCertificafe.loadPEMFile(_:).first`, which isn't necessarily the same (the error flow is different for one). To avoid any subtle behaioral changes revert back to the old API in that one instance. Modifications: - Use old API Result: Fewer behavioural changes --- Sources/NIOSSL/SSLCertificate.swift | 2 +- Sources/NIOSSL/SSLContext.swift | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/NIOSSL/SSLCertificate.swift b/Sources/NIOSSL/SSLCertificate.swift index c5d779da..a28f0051 100644 --- a/Sources/NIOSSL/SSLCertificate.swift +++ b/Sources/NIOSSL/SSLCertificate.swift @@ -106,7 +106,7 @@ public final class NIOSSLCertificate { /// - parameters: /// - file: The path to the file to load the certificate from. /// - format: The format to use to parse the file. - private convenience init(_file file: String, format: NIOSSLSerializationFormats) throws { + internal convenience init(_file file: String, format: NIOSSLSerializationFormats) throws { let fileObject = try Posix.fopen(file: file, mode: "rb") defer { fclose(fileObject) diff --git a/Sources/NIOSSL/SSLContext.swift b/Sources/NIOSSL/SSLContext.swift index 5d49a731..72db48b9 100644 --- a/Sources/NIOSSL/SSLContext.swift +++ b/Sources/NIOSSL/SSLContext.swift @@ -688,9 +688,8 @@ extension NIOSSLContext { // Load only the certificates that resolve to an existing certificate in the directory. for symPath in certificateFilePaths { // c_rehash only support pem files. - if let cert = try NIOSSLCertificate.fromPEMFile(symPath).first { - try addCACertificateNameToList(context: context, certificate: cert) - } + let cert = try NIOSSLCertificate(_file: symPath, format: .pem) + try addCACertificateNameToList(context: context, certificate: cert) } } }