@@ -36,9 +36,9 @@ public struct APNSwiftSigner {
3636 let bio = BIO_new ( BIO_s_mem ( ) )
3737 defer { BIO_free ( bio) }
3838 let res = buffer. withUnsafeReadableBytes { ptr in
39- Int ( BIO_puts ( bio, ptr. baseAddress? . assumingMemoryBound ( to : Int8 . self ) ) )
39+ BIO_write ( bio, ptr. baseAddress, CInt ( ptr . count ) )
4040 }
41- assert ( res >= 0 , " BIO_puts failed" )
41+ assert ( res >= 0 , " BIO_write failed" )
4242
4343 guard let opaquePointer = OpaquePointer . make ( optional: PEM_read_bio_ECPrivateKey ( bio!, nil , nil , nil ) ) else {
4444 throw APNSwiftError . SigningError. invalidAuthKey
@@ -50,17 +50,14 @@ public struct APNSwiftSigner {
5050 }
5151 defer { ECDSA_SIG_free ( sig) }
5252
53- var derEncodedSignature : UnsafeMutablePointer < UInt8 > ?
53+ var derEncodedSignature : UnsafeMutablePointer < CUnsignedChar > ?
5454 let derLength = i2d_ECDSA_SIG ( sig, & derEncodedSignature)
5555 guard let derCopy = derEncodedSignature, derLength > 0 else {
5656 throw APNSwiftError . SigningError. invalidASN1
5757 }
5858
5959 var derBytes = ByteBufferAllocator ( ) . buffer ( capacity: Int ( derLength) )
60- for b in 0 ..< Int ( derLength) {
61- derBytes. writeBytes ( [ derCopy [ b] ] )
62- }
63-
60+ derBytes. writeBytes ( UnsafeBufferPointer < CUnsignedChar > ( start: derCopy, count: Int ( derLength) ) )
6461 return derBytes
6562 }
6663}
0 commit comments