Skip to content

Digitally Signed QR Codes


QR codes generated by the mobile services cockpit are not digitally signed by default. This may allow a vulnerability to arise, whereby an attacker could create a QR code with a malicious URL and share it with users via email or by other means. If the compromised QR code is used for onboarding, the app will connect to the malicious URL and, as a result, sensitive data breaches could occur.

In order to mitigate this vulnerability, you can use digitally-signed QR codes, where QR codes generated by the mobile services cockpit get digitally signed.

How Does It Work

The SAP BTP SDK for iOS doesn't rely on any kind of wizardry. Under the hood it makes use of well known concepts in Public key cryptography and JWS (JSON Web Signature) to accomplish this.

When this feature is enabled (either via mobile services cockpit or SAP BTP SDK Assistant for iOS), a private-public key pair is generated by the mobile services cockpit. The private key is used by mobile services cockpit to sign the QR codes. The public key is used by the application / SDK for digital signature verification.

When the SDK scans a signed QR code, the result is a JWS string. The digital signature on JWS string is verified first, which in turn ascertains the authenticity and integrity of the actual message. If signature verification is successful, the onboarding flow will proceed to the next steps in the flow. If verification is unsuccessful, authentication is identified as failed.

Below is the list of supported key-pair and algorithm.

Key Pair Type Key Length JWS Algorithm Used Hash
RSA 2048 RS256 SHA-256
RSA 3072 RS384 SHA-384
RSA 4096 RS512 SHA-512
EC 256 ES256 SHA-256
EC 384 ES384 SHA-384
EC 512 ES512 SHA-512


  • If the feature is enabled using the SAP BTP SDK Assistant for iOS while generating the app, a public key is made available in the Xcode project and is added to the app target as part of the app generation process.
  • If the feature is enabled using the mobile services cockpit, then the public key should be made available to the app and SDK. In order to do so, add the Digital Signature Public Key key in AppParameters.plist with a value that points to the file name in which the public key is stored. Make sure that the public key file is added to the app target.

Enabling QR Code Digital Signature Verification

To enable signature verification, you need to make changes to the WelcomeScreenStep:

let welcomeScreenStep = WelcomeScreenStep(transformer: discoveryConfigurationTransformer, providers: [JSONConfigurationProvider()])
welcomeScreenStep.welcomeScreenCustomizationHandler = { welcomeStepUI in
            if let welcomeScreen = welcomeStepUI as? FUIWelcomeScreen {
                welcomeScreen.configurationOptions = [.barcodeScanner]

This enables opening the scanner in order to scan the QR code.

To enable signature verification, add the following:

welcomeScreenStep.isDigitallySignedQRCodeEnabled = true

On a successful verification the user can continue with rest of the onboarding process. verification-successful

For a failed verification appropriate reason for failure is logged and onboarding fails. verification-failed

Digital Signature Verification Using Cross Context SSO

Using Cross Context SSO, the user can open the onboarding URL in a device browser.

If QR Code Signature Settings is enabled in the mobile services cockpit, then the URL that opens the app is encoded.

The signature on the encoded URL has to be verified for the onboarding process to start.

To accomplish this, add the following in AppDelegate.swift:

func application(_: UIApplication, open url: URL, options _: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
            if incomingURL.absoluteString.range(of: "jws=") != nil {
                let provider = URLConfigurationProvider()
                let result = AppDelegateDispatcher.application(app, open: incomingURL)
                if result == false {
                    flowProvider.urlConfigurationProvider = nil
                } else {
                    flowProvider.urlConfigurationProvider = provider
                    window!.rootViewController = FUIInfoViewController.createSplashScreenInstanceFromStoryboard()
                // regular onboarding code
                return result
            } else {
                return false


If you use SAP BTP SDK Assistant for iOS, the required code described above is automatically created as part of the app generation process.

Last update: September 27, 2022