Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit e6901e6

Browse files
authored
Bug fixes
1 parent 44e00e3 commit e6901e6

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import <openssl/x509.h>
2-
#import <openssl/ssl.h>
3-
#import <openssl/err.h>
4-
#import <openssl/crypto.h>
1+
#include <openssl/x509.h>
2+
#include <openssl/ssl.h>
3+
#include <openssl/err.h>
4+
#include <openssl/crypto.h>

Sources/prostore/certificates/certificates.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Sources/prostore/certificates/certificates.swift
2-
// Put this file under Sources/prostore/certificates/
3-
41
import Foundation
52
import Security
63
import CryptoKit
@@ -36,8 +33,8 @@ public final class CertificatesManager {
3633
var cfErr: Unmanaged<CFError>?
3734
guard let keyData = SecKeyCopyExternalRepresentation(secKey, &cfErr) as Data? else {
3835
if let cfError = cfErr?.takeRetainedValue() {
39-
// Fixed: Remove force casting CFError to NSError
40-
let nsError = cfError as NSError
36+
// Fixed: Force cast CFError to NSError
37+
let nsError = cfError as! NSError
4138
throw CertificateError.publicKeyExportFailed(OSStatus(nsError.code))
4239
} else {
4340
throw CertificateError.publicKeyExportFailed(-1)
@@ -73,14 +70,14 @@ public final class CertificatesManager {
7370
}
7471

7572
// Fixed: Proper cast for signers to OpaquePointer (assuming signers is UnsafeMutableRawPointer)
76-
let stackPtr = OpaquePointer(UnsafeMutableRawPointer(signers)) // Tweak this if signers type is different
73+
let stackPtr = OpaquePointer(UnsafeMutableRawPointer(signers))
7774

7875
// Use OPENSSL_sk_num and OPENSSL_sk_value with proper index types
7976
let count = Int(OPENSSL_sk_num(stackPtr))
8077
for i in 0..<count {
8178
guard let rawVal = OPENSSL_sk_value(stackPtr, Int32(i)) else { continue }
8279
// rawVal is UnsafeMutableRawPointer; interpret as X509*
83-
let x509Ptr = rawVal.assumingMemoryBound(to: X509.self) // X509 should be in scope now
80+
let x509Ptr = rawVal.assumingMemoryBound(to: X509.self)
8481

8582
// convert X509 -> DER
8683
var derPtr: UnsafeMutablePointer<UInt8>? = nil
@@ -101,7 +98,6 @@ public final class CertificatesManager {
10198
}
10299

103100
// Fixed warning: Safer way to cast the free func without unsafeBitCast
104-
// Use a closure or direct cast if possible; here's a workaround
105101
OPENSSL_sk_pop_free(stackPtr) { ptr in
106102
X509_free(OpaquePointer(ptr))
107103
}

0 commit comments

Comments
 (0)