Posts

Post not yet marked as solved
2 Replies
225 Views
I have a .p12 file which contains two certificates, but no identities. When attempting to use SecPKCS12Import against it it returns a success code, but the CFArray is empty: func testParsingCert() throws { let bundle = Bundle(for: Self.self) let certificateURL = bundle.url(forResource: TestConstants.SERVER_CERTIFICATE_NAME, withExtension: TestConstants.CERTIFICATE_FILE_EXTENSION)! let certificateData = try! Data(contentsOf: certificateURL) var importResult: CFArray? = nil let err = SecPKCS12Import( certificateData as NSData, [kSecImportExportPassphrase as String: TestConstants.DEFAULT_CERT_PASSWORD] as NSDictionary, &importResult ) guard err == errSecSuccess else { throw NSError(domain: NSOSStatusErrorDomain, code: Int(err), userInfo: nil) } let identityDictionaries = importResult as! [[String:Any]] var chain: CFArray chain = identityDictionaries[0][kSecImportItemCertChain as String] as! CFArray print(chain) } Above code fails with Test Case '-[TAKTrackerTests.CertificateSigningRequestTests testParsingCert]' started. Swift/ContiguousArrayBuffer.swift:600: Fatal error: Index out of range as the identityDictionaries result contains no results (nor does importResult) The specific use case for this is that users can do Certificate Enrollment against a server with a self-signed certificate, so they need to be able to upload the trust store prior to connecting for identities.
Posted
by cory_foy.
Last updated
.
Post not yet marked as solved
1 Replies
581 Views
Hi All, I have a Swift Package I'm building. I need to import an existing C++ Static Library into this package. It seems to build fine, but when I attempt to run the tests I get a weird linker error. I've put a repro repo up at https://github.com/flighttactics/CppIssueRepro Here's the steps I took: I have the C++ library's .a file and the headers. I created a folder in my package for the library, drug the include folder into it, and then added the .a file at the root of the folder. I created an Umbrella header in the include folder, along with a module.modulemap. I then created a shim file (per https://github.com/apple/swift-package-manager/issues/5706) Finally, I modified my package file to build the target, and reference it as a dependency (Note I also had to go into the GeographicLib headers for DST and comment out two functions I'm not using which reference std::function since that's not supported by Swift) I find that including the library module works in the main code base, and I can build successfully. However, when I attempt to run tests against the main code base when it's calling into the C++ library I'm getting the following build error: ld: Undefined symbols: double GeographicLib::Math::AngNormalize<double>(double), referenced from: GeographicLib::GeoCoords::Reset(double, double, int) in CppIssueRepro.o GeographicLib::UTMUPS::Forward(double, double, int&, bool&, double&, double&, double&, double&, int, bool), referenced from: GeographicLib::GeoCoords::Reset(double, double, int) in CppIssueRepro.o GeographicLib::GeoCoords::MGRSRepresentation(int) const, referenced from: CppIssueRepro.CoordinateCalculator.coverttoMGRS(lat: Swift.Double, lon: Swift.Double) -> Swift.String in CppIssueRepro.o clang: error: linker command failed with exit code 1 (use -v to see invocation) Again, if my main code does not call into the C++ library I'm able to run tests and build just fine. Not sure what else I can do - it seems like I'm following everything based on the 5.9 docs but I also feel I'm maybe missing something really simple here.
Posted
by cory_foy.
Last updated
.