From 2ad03d4fac8192659dc4d9e673936eb23468f27c Mon Sep 17 00:00:00 2001 From: Filippos Sakellaropoulos Date: Wed, 7 Feb 2024 01:18:38 +0200 Subject: [PATCH] use subjectDistinguishedName for openID4vp verifier, update packages --- Package.resolved | 8 ++++---- .../Services/OpenId4VpService.swift | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Package.resolved b/Package.resolved index e5f7a25..653c192 100644 --- a/Package.resolved +++ b/Package.resolved @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-transfer.git", "state" : { - "revision" : "268ef13b1bbe58a14b966b6ad336adddddda657a", - "version" : "0.1.9" + "revision" : "332031d65fdf15bd7d2938849891a756fd6dccec", + "version" : "0.2.0" } }, { @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-security.git", "state" : { - "revision" : "4c8b26fbdbcf8c6110a0e12ba49c59c8158a1b12", - "version" : "0.1.7" + "revision" : "c0d935b3919f8e7a383f6b60b4b592abf6afd689", + "version" : "0.1.8" } }, { diff --git a/Sources/eudi-lib-ios-wallet-kit/Services/OpenId4VpService.swift b/Sources/eudi-lib-ios-wallet-kit/Services/OpenId4VpService.swift index fd46275..1d427eb 100644 --- a/Sources/eudi-lib-ios-wallet-kit/Services/OpenId4VpService.swift +++ b/Sources/eudi-lib-ios-wallet-kit/Services/OpenId4VpService.swift @@ -24,10 +24,7 @@ import MdocDataTransfer18013 import SiopOpenID4VP import JOSESwift import Logging -#if canImport(UIKit) -import UIKit -import SafariServices -#endif +import ASN1Decoder /// Implements remote attestation presentation to online verifier /// Implementation is based on the OpenID4VP – Draft 18 specification @@ -82,7 +79,7 @@ public class OpenId4VpService: PresentationService { var result: [String: Any] = [UserRequestKeys.valid_items_requested.rawValue: items] if let readerCertificateIssuer { result[UserRequestKeys.reader_auth_validated.rawValue] = readerAuthValidated - result[UserRequestKeys.reader_certificate_issuer.rawValue] = readerCertificateIssuer + result[UserRequestKeys.reader_certificate_issuer.rawValue] = MdocHelpers.getCN(from: readerCertificateIssuer) result[UserRequestKeys.reader_certificate_validation_message.rawValue] = readerCertificateValidationMessage } return result @@ -139,8 +136,8 @@ public class OpenId4VpService: PresentationService { let verified = try? chainVerifier.verifyCertificateChain(base64Certificates: certificates) var result = chainVerifier.isChainTrustResultSuccesful(verified ?? .failure) guard let self, let b64cert = certificates.first, let data = Data(base64Encoded: b64cert), let str = String(data: data, encoding: .utf8) else { return result } - guard let encodedData = Data(base64Encoded: str.removeCertificateDelimiters()), let cert = SecCertificateCreateWithData(nil, encodedData as CFData) else { return result } - var cfName: CFString?; SecCertificateCopyCommonName(cert, &cfName); self.readerCertificateIssuer = cfName as String? + guard let certData = Data(base64Encoded: str.removeCertificateDelimiters()), let cert = SecCertificateCreateWithData(nil, certData as CFData), let x509 = try? X509Certificate(der: certData) else { return result } + self.readerCertificateIssuer = x509.subjectDistinguishedName let (isValid, reason, _) = SecurityHelpers.isValidMdlPublicKey(secCert: cert, usage: .mdocAuth, rootCerts: self.iaca) self.readerAuthValidated = isValid self.readerCertificateValidationMessage = reason