Handling verifier authentication results
Use the verifier authentication result, identity metadata and authorization the Holder SDK reports to decide how your wallet handles a presentation request.
Open preview
Verifier identity and authorization is offered as an open preview in the iOS Holder SDK 7.0.0 and the Android Holder SDK 8.0.0. The data structures described on this page can change before the feature is generally available.
Overview
This guide shows how your wallet can use the verifier authentication result, the relying party's identity metadata and its authorization to decide how to handle a presentation request.
For an explanation of the data itself, see Verifier identity and authorization.
Prerequisites
- A holder application that can receive presentation requests. Complete the Proximity Presentation tutorial or the Remote Presentation tutorial first.
- The verifier root CA certificates your wallet should trust, obtained from the verifiers or from the trust framework your wallet participates in.
Step 1: Trust the verifier root certificates
A request can only be trusted, and its identity metadata and authorization can only be reported, when its certificate chain ends at a certificate your wallet trusts. Add the verifier root CA certificates your wallet trusts as described in how to manage trusted verifier certificates. The same store is used for in-person, remote and Digital Credentials API presentations.
Step 2: Read the verifier information
Write a helper that returns the VerifierInfo for a request, or nothing when the request is not
trusted. The examples below cover in-person presentations, where each requested document carries its
own result. For remote presentations, read verifiedBy on the session instead. See
Verifier identity and authorization
for every channel.
import MobileCredentialHolderSDK
func verifierInfo(for request: MobileCredentialRequest) -> VerifierInfo? {
switch request.verifierAuthenticationResult {
case .trusted(let verifierInfo):
return verifierInfo
case .untrusted, .unsigned:
return nil
@unknown default:
return nil
}
}
// Remote (OpenID4VP) presentations
func verifierInfo(for session: OnlinePresentationSession) -> VerifierInfo? {
if case .certificate(let verifierInfo) = session.verifiedBy {
return verifierInfo
}
return nil
}Step 3: Show the relying party's identity
When the request is trusted and carries identity metadata, show the display name prominently on your consent screen, and show the logo when your wallet can retrieve it. Fall back to the trusted root's common name when there is no display name, so the user always sees who is asking.
If the certificate includes a logo hash, compare it with the SHA-256 digest of the image your wallet retrieved. If they do not match, show the display name without the logo, because the image at the URI is not the one the certificate refers to.
import CryptoKit
func verifierLabel(_ verifierInfo: VerifierInfo) -> String {
verifierInfo.identityMetadata?.displayName ?? verifierInfo.commonName
}
/// Returns the logo bytes, or nil when the logo is unavailable or does not match its hash.
func loadLogo(_ logo: VerifierInfo.LogoInfo) async -> Data? {
guard let url = URL(string: logo.logoUri), url.scheme == "https",
let (data, response) = try? await URLSession.shared.data(from: url),
(response as? HTTPURLResponse)?.statusCode == 200 else {
return nil
}
if let expectedHash = logo.logoHash, Data(SHA256.hash(data: data)) != expectedHash {
return nil
}
return data
}Retrieving the logo contacts a host the relying party controls. If that is a concern for your wallet,
retrieve logos only after the user chooses to continue, or cache them per logoUri.
Step 4: Compare the request with the authorization
For each requested element, work out whether the relying party is authorized to request it. There are three possible answers:
- Authorized: The element is covered by the authorization, with an optional retention flag.
- Not authorized: The authorization lists elements, and this element is not among them.
- No statement: The certificates carry no element authorization, so there is nothing to compare against.
Apply the same rules the SDK documents for the authorization data: a document type with no namespaces authorizes all its elements, and a namespace with no elements authorizes all the elements in it.
enum ElementAuthorization: Equatable {
case authorized(retain: Bool?)
case notAuthorized
case noStatement
}
func elementAuthorization(
_ authorization: VerifierInfo.Authorization?,
docType: String,
namespace: String,
elementId: String
) -> ElementAuthorization {
guard let authorizedElements = authorization?.authorizedElements else { return .noStatement }
guard let document = authorizedElements.first(where: { $0.docType == docType }) else { return .notAuthorized }
if document.namespaces.isEmpty { return .authorized(retain: nil) }
guard let elements = document.namespaces[namespace] else { return .notAuthorized }
if elements.isEmpty { return .authorized(retain: nil) }
guard let retain = elements[elementId] else { return .notAuthorized }
return .authorized(retain: retain)
}Each requested element also carries the verifier's intent to retain it. Compare the two: a verifier that intends to keep an element it is only authorized to view is asking for more than it is permitted.
Step 5: Decide how to handle the request
How your wallet handles a request is a policy decision that depends on your ecosystem, your users and how sensitive the requested data is. Combine the verifier authentication result, the identity metadata and the authorization to identify which situation applies:
| Situation | What it tells you | Example |
|---|---|---|
| Trusted, identity metadata present, every requested element authorized | The verifier is who it says it is, and the request stays within its authorization. | A bar's door scanner requests age_over_18 from an mDL. The certificate names "Harbor Street Bar" and authorizes age_over_18. |
| Trusted, and the verifier intends to keep an element it is authorized to keep | The request is within scope, and the verifier will retain some data after the interaction. | A car rental desk requests family_name, document_number and driving_privileges, intends to keep them, and is authorized to keep them. |
| Trusted, but no identity metadata | The verifier is authenticated, but its certificate does not say how to present it to the user. | A verifier whose certificate authority does not add identity metadata. |
| Trusted, but the logo cannot be retrieved or does not match its hash | The display name is reliable, but the image at the logo URI cannot be shown as the verifier's logo. | An in-person presentation with no network connection. |
| Trusted, but a requested element is not authorized | The verifier is asking for more than its certificate authority permits. | The bar's scanner also requests resident_address, which its authorization does not include. |
| Trusted, but the verifier intends to keep an element it is not authorized to keep | The verifier is asking to retain data it is only authorized to view. | A venue intends to keep portrait, which is authorized with retention false. |
| Trusted, and authorized purposes name a controller your wallet does not recognize | The authorization comes from a trust framework your wallet has not onboarded. | A purpose controller from a trust network your wallet does not know. |
Untrusted with ExpiredCertificate or InactiveCertificate | The certificate chains to a trusted root, but is outside its validity period. | A verifier device whose signer certificate expired while it was offline. |
Untrusted with CertificateNotFound, InvalidVerifierCertificate or FailedToEvaluateTrust | The verifier's identity could not be established. | A request signed by a certificate that does not chain to any root your wallet trusts. |
| Unsigned | The request carries no proof of who sent it. | A verifier that does not sign its requests asks for portrait and document_number. |
The following example shows one way to combine these values for an in-person request. It is not a recommended policy. We include it to show how the result, identity metadata and authorization from the previous steps fit together in code. This example wallet rejects unsigned requests and requests it cannot authenticate, flags expired certificates and any request that goes beyond the verifier's authorization, and accepts everything else. It returns a decision your consent screen can act on.
enum RequestDecision {
case accept(verifier: String)
case flag(verifier: String, warnings: [String])
case reject(reason: String)
}
func decide(_ request: MobileCredentialRequest) -> RequestDecision {
switch request.verifierAuthenticationResult {
case .unsigned:
return .reject(reason: "The verifier did not sign its request.")
case .untrusted(_, let error):
switch error {
case .expiredCertificate, .inactiveCertificate:
return .flag(verifier: "Unverified verifier", warnings: [error.localizedDescription])
default:
return .reject(reason: error.localizedDescription)
}
case .trusted(let verifierInfo):
var warnings: [String] = []
if verifierInfo.identityMetadata?.displayName == nil {
warnings.append("The verifier did not provide display details.")
}
for (namespace, elements) in request.namespaces {
for (elementId, intentToRetain) in elements {
switch elementAuthorization(verifierInfo.authorization,
docType: request.docType,
namespace: namespace,
elementId: elementId) {
case .notAuthorized:
warnings.append("The verifier is not authorized to request \(elementId).")
case .authorized(let retain) where intentToRetain && retain == false:
warnings.append("The verifier is not authorized to keep \(elementId).")
default:
break
}
}
}
let label = verifierLabel(verifierInfo)
return warnings.isEmpty ? .accept(verifier: label) : .flag(verifier: label, warnings: warnings)
@unknown default:
return .reject(reason: "The verifier could not be authenticated.")
}
}Run the decision before you show the consent screen, then respond with the user's choice as shown in the Proximity Presentation tutorial.
What's next
- Verifier identity and authorization: How the data is carried and processed.
- Handling verifier authentication (remote): Configure
how strictly remote requests are validated with
requireTrustedVerifier.
How would you rate this page?
Last updated on