Skip to content

Commit

Permalink
validate reader auth using full x5c chain
Browse files Browse the repository at this point in the history
  • Loading branch information
phisakel committed Oct 9, 2024
1 parent df6ec3d commit 1e12aef
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Sources/MdocDataTransfer18013/MdocHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public class MdocHelpers {
var userRequestInfo = UserRequestInfo(validItemsRequested: validRequestItems, errorItemsRequested: errorRequestItems)
if let docR = deviceRequest.docRequests.first {
let mdocAuth = MdocReaderAuthentication(transcript: sessionEncryption.transcript)
if let readerAuthRawCBOR = docR.readerAuthRawCBOR, let certData = docR.readerCertificate, let x509 = try? X509.Certificate(derEncoded: [UInt8](certData)), let (b,reasonFailure) = try? mdocAuth.validateReaderAuth(readerAuthCBOR: readerAuthRawCBOR, readerAuthCertificate: certData, itemsRequestRawData: docR.itemsRequestRawData!, rootCerts: iaca) {
//params[UserRequestKeys.reader_certificate_issuer.rawValue]
if let readerAuthRawCBOR = docR.readerAuthRawCBOR, case let certData = docR.readerCertificates, certData.count > 0, let x509 = try? X509.Certificate(derEncoded: [UInt8](certData.first!)), let (b,reasonFailure) = try? mdocAuth.validateReaderAuth(readerAuthCBOR: readerAuthRawCBOR, readerAuthX5c: certData, itemsRequestRawData: docR.itemsRequestRawData!, rootCerts: iaca) {
userRequestInfo.readerCertificateIssuer = MdocHelpers.getCN(from: x509.subject.description)
userRequestInfo.readerAuthValidated = b
if let reasonFailure { userRequestInfo.readerCertificateValidationMessage = reasonFailure }
Expand Down

0 comments on commit 1e12aef

Please sign in to comment.