Skip to content

Commit 1edc34b

Browse files
authored
PackageCollectionsSigning: correct BoringSSLCertificate.keyType(of:) (#3679)
This function takes a named argument which is the `EVP_PKEY` and checks the underlying public key type (expected to be one of RSA or EC). However, instead of checking the key type of the given public key, it was always returning the key type of the underlying certificate. This happened to give the correct result as the current usage always used the same object to get the key. This corrects that and uses the proper accessors for the value.
1 parent 2d7b2bc commit 1edc34b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/PackageCollectionsSigning/Certificate/Certificate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ final class BoringSSLCertificate {
181181
}
182182

183183
private func keyType(of key: UnsafeMutablePointer<EVP_PKEY>) throws -> KeyType {
184-
let algorithm = CCryptoBoringSSL_OBJ_obj2nid(self.underlying.pointee.cert_info.pointee.key.pointee.algor.pointee.algorithm)
184+
let algorithm = CCryptoBoringSSL_EVP_PKEY_id(key)
185185

186186
switch algorithm {
187187
case NID_rsaEncryption:

0 commit comments

Comments
 (0)