apple / swift-nio-ssl

TLS Support for SwiftNIO, based on BoringSSL.
https://swiftpackageindex.com/apple/swift-nio-ssl/main/documentation/niossl
Apache License 2.0
393 stars 142 forks source link

Add API to create PKCS#12 #486

Closed gjcairo closed 3 weeks ago

gjcairo commented 1 month ago

Motivation

It would be handy to provide an API to create PKCS#12 files from a list of NIOSSLCertificates and a NIOSSLPrivateKey. This would be particularly useful when dealing with Network.framework/NIOTransportServices/Security.framework, which use SecIdentitys for SSL. Two particular use cases are https://github.com/apple/swift-nio-ssl/issues/484#issuecomment-2410375188 and grpc-swift-nio-transport, which would use this API for testing the NIOTS transport implementation.

Modifications

This PR adds a static method to NIOSSLPKCS12Bundle that creates a PKCS#12 file from the given array of certificates + private key, and returns it as an array of bytes.

Result

PKCS#12 files can be created using NIOSSL.