SIM Signing using CIBA (PKCS1)

Step by step instructions for service providers on how to Signing using CIBA and SIM certificate.

Table of Contents

 

Requirements

For all steps to be successful the following must be at hand.

During setup

  • Client Id (received from Auðkenni)

  • Client secret (received from Auðkenni)

  • Related party (not necessary)

  • Base URI (received from Auðkenni)

  • Private Key (to sign a JSON Web Token)

  • Public Key (to give to Auðkenni for configuration)

Information needed at runtime

  • User’s mobile number

  • Message text for user (Including any verification messages: number, text etc.)

 

Setup requirements used in the examples

  • Client id: myCibaClientId

  • Client secret: MyApiClientP4$sW

  • Base URI: pfzww.audkenni.is

  • Private Key: Not shown here for security reasons

  • Public Key: Not shown

All code examples are generated using Postman. They are therefore only for demo.

 

Step 1

Step 1: (Creating JSON Web Token)

The first step is to create a signed JWT to use for CIBA communication.

What the JWT need to include

  • login_hint (the users mobile number)

  • scope (openid, profile, signature. Also possible to add “related party” info here (see example))

  • acr_values (“sim-sign-pkcs1”. This value is different between authentication/signing methods)

  • iss (the Client id)

  • aud (Should have “https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni“)

  • exp (the lifetime of the token)

  • binding_message (the message to display at users mobile device)

  • binding_content (base64 string of a SHA256 hash)

Also needed to create the JWT

  • Private key (to sign the JWT)

  • Alg info (Should be “RS256”)

Example of JWT

1 eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJsb2dpbl9oaW50IjoiOTg3NjU0MyIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgc2lnbmF0dXJlIFJFTEFURURQQVJUWTpNeU93bkNsaWVudCIsImFjcl92YWx1ZXMiOiJzaW0tc2lnbi1wa2NzMSIsImlzcyI6Im15Q2liYUNsaWVudElkIiwiYXVkIjoiaHR0cHM6Ly9wZnp3dy5hdWRrZW5uaS5pczo0NDMvc3NvL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYXVka2VubmkiLCJleHAiOjE2MTExNDk0NTkuMTIyLCJiaW5kaW5nX21lc3NhZ2UiOiJBdcOwa2VubmkgU0lNIFNpZ25pbmciLCJiaW5kaW5nX2NvbnRlbnQiOiJQR1RMZitkeUtZU0EvR0tRMnJacUVRZXBmL3JZSExnZ0pyY3RZa0xHYlN3PSJ9.DRHn9-ueuLhr0y3RMu7NTS6_i3L2LbxLbwhnZg8JO6oLwmHtXenZXRGpF3n6Lgo3YRZPhpK6Tc_6kvMHmTyMQW2g2fTyFMylX2Z19rWwS5oHqTFGaqfLuePhzSxIFPUI56ofKp6jS4mb1dC85mxKrMxgvrlBgIlvA_rx9DqNUgSYyETzeBELlTwWdTOhJuCv-N53Ngt7Ro-s_FDceyOeVl_V-BJALO8Y6r2PF2DkKYFHW-4ykQc_MX3lhJYdaY6w26yYC1XkggmXsLz-JWVbwveB0JMv_5j2j6OiPnuKhkFWAoVKlS0rVENZCSZ_rptgPq9VT7ajlyeebB8mbcSm7w

 

Example of JWT Payload

1 2 3 4 5 6 7 8 9 10 { "login_hint": "9876543", "scope": "openid profile signature RELATEDPARTY:MyOwnClient", "acr_values": "sim-sign-pkcs1", "iss": "myCibaClientId", "aud": "https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni", "exp": 1611149459.122, "binding_message": "Auðkenni SIM Signing", "binding_content": "PGTLf+dyKYSA/GKQ2rZqEQepf/rYHLggJrctYkLGbSw=" }

 

 

Step 2

 

Step 2: (Sign)

To sign using mobile (SIM) we send a POST call to following URI:
https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/bc-authorize

 

Parameters needed in call

We need to add following header parameter

  • A Basic Auth header, using the Client id and Client secret

We need to add following parameter

  • request (the value should be the JWT from step 1)

 

CURL example of the call

1 2 3 4 curl --location --request POST 'https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/bc-authorize' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Authorization: Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw==' \ --data-urlencode 'request=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJsb2dpbl9oaW50IjoiNjE3ODg4OCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgc2lnbmF0dXJlIFJFTEFURURQQVJUWTpNeU93bkNsaWVudCIsImFjcl92YWx1ZXMiOiJzaW0tc2lnbiIsImlzcyI6Im15Q2liYUNsaWVudElkIiwiYXVkIjoiaHR0cHM6Ly9wZnp3dy5hdWRrZW5uaS5pczo0NDMvc3NvL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYXVka2VubmkiLCJleHAiOjE2MTExNDIzMDAuMSwiYmluZGluZ19tZXNzYWdlIjoiQXXDsGtlbm5pIFNJTSBTaWduaW5nIiwiYmluZGluZ19jb250ZW50IjoiUEdUTGYrZHlLWVNBL0dLUTJyWnFFUWVwZi9yWUhMZ2dKcmN0WWtMR2JTdz0ifQ.TpDlBSbcmY11lD-725snq_Hn-vAN1T5SA_-9FT8l7k2Wwax6MtD1qF_2kPFUvV6-xsK1mK-lMqpmqUlwctkE8zIUkMtc-vrmunfaHin9EvkNGPCfjV7FfCZdzSZMrz1YombfC6Vte3dC33AMxTimMZkD3lRwnlX-lHap00ERbZReEngt10ZvEJgrjOY3Z6jROgMCLSBDkPs3mAEZSfcimYpXjiNUUa5Pras-kD7HgisAtVP-9eTBQeCwoM_rsYEXSsrkhNBYj_JTLt3Q5z3zqTj2km-Rwl4ITn9yAn055fC2FnPOTbHQ2sHahqVdDlLBMSUOhkdn3N9syx1-NOUjsw'

 

C# - RestSharp example of the call

1 2 3 4 5 6 7 8 var client = new RestClient("https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/bc-authorize"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw=="); request.AddParameter("request", "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJsb2dpbl9oaW50IjoiNjE3ODg4OCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgc2lnbmF0dXJlIFJFTEFURURQQVJUWTpNeU93bkNsaWVudCIsImFjcl92YWx1ZXMiOiJzaW0tc2lnbiIsImlzcyI6Im15Q2liYUNsaWVudElkIiwiYXVkIjoiaHR0cHM6Ly9wZnp3dy5hdWRrZW5uaS5pczo0NDMvc3NvL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYXVka2VubmkiLCJleHAiOjE2MTExNDIzMDAuMSwiYmluZGluZ19tZXNzYWdlIjoiQXXDsGtlbm5pIFNJTSBTaWduaW5nIiwiYmluZGluZ19jb250ZW50IjoiUEdUTGYrZHlLWVNBL0dLUTJyWnFFUWVwZi9yWUhMZ2dKcmN0WWtMR2JTdz0ifQ.TpDlBSbcmY11lD-725snq_Hn-vAN1T5SA_-9FT8l7k2Wwax6MtD1qF_2kPFUvV6-xsK1mK-lMqpmqUlwctkE8zIUkMtc-vrmunfaHin9EvkNGPCfjV7FfCZdzSZMrz1YombfC6Vte3dC33AMxTimMZkD3lRwnlX-lHap00ERbZReEngt10ZvEJgrjOY3Z6jROgMCLSBDkPs3mAEZSfcimYpXjiNUUa5Pras-kD7HgisAtVP-9eTBQeCwoM_rsYEXSsrkhNBYj_JTLt3Q5z3zqTj2km-Rwl4ITn9yAn055fC2FnPOTbHQ2sHahqVdDlLBMSUOhkdn3N9syx1-NOUjsw"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

 

 

Step 2: Expected response

The CIBA service answer is in JSON format.

When Step 2 is executed the signing process at the users device starts.

The response should include following

  • auth_req_id (to use in next step)

  • expires_in (the lifetime of th id)

  • interval

 

Example of answer from Step 2

1 2 3 4 5 { "auth_req_id": "8ag4NXa4ctFJuv1h9EtUnfNeFww", "expires_in": 600, "interval": 2 }

 

 

Step 3

 

Step 3: (Poll for token)

After executing Step 2 the signing process at the users device starts. It depends on the user, the device and the network how long time this process takes.

In this step we poll for results from the signing process. When signing process is finished successfully you will receive answer with Access and Id token of the user.

To poll for tokens we send another POST call to following URI:
https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/access_token

 

Parameters needed in call

We need to add following header parameter

  • A Basic Auth header, using the Client id and Client secret

We need to add following parameter

  • grant_type (the value should be: “urn:openid:params:grant-type:ciba”)

  • auth_req_id (the value should be the auth_req_id from last step answer)

 

CURL example of the call

1 2 3 4 5 curl --location --request POST 'https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/access_token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Authorization: Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw==' \ --data-urlencode 'grant_type=urn:openid:params:grant-type:ciba' \ --data-urlencode 'auth_req_id=P8ZFeExVCVs0oFfbGDpG4CUv_D4'

 

C# - RestSharp example of the call

1 2 3 4 5 6 7 8 9 var client = new RestClient("https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/access_token"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw=="); request.AddParameter("grant_type", "urn:openid:params:grant-type:ciba"); request.AddParameter("auth_req_id", "P8ZFeExVCVs0oFfbGDpG4CUv_D4"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

 

 

Step 3: Expected response (Signing still in process)

If you run the poll call before the user signing process is finished you will receive a answer notifying the process isn’t finished.

The REST API service answer is in JSON format.

If you get answer like this you need to wait for short time and run Step 3 call again.

The response should include following

  • error_description

  • error

Example of answer from Step 3

1 2 3 4 { "error_description": "End user has not yet been authenticated", "error": "authorization_pending" }

 

Step 3: Expected response (Signing is finished)

The answer from this call should give you the Access and Id tokens along type and lifetime info.

The Id token contains a PKCS1 signature and a signing certificate.

The REST API service answer is in JSON format.

Best practice

Best practice is to verify the signature and the certificate. Verify the user’s info in the Id token against the certificate. By decoding the signature using the certificate you should end up with the hash from the earlier step.

The response should include following

  • access_token

  • scope

  • id_token

  • token_type

  • expires_in (lifetime of the tokens)

Example of answer from step 3

1 2 3 4 5 6 7 { "access_token": "eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT05FIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiIxMDkwNWYxZS0yNjA4LTRmOWMtODBkMi0zZmI0NTI0MTUyMmMiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiZWQ5NzcwMTgtOWMxYy00MDM3LWFkNTgtYzYxZGMyMjQ4MGE4LTExNzI3MDkiLCJpc3MiOiJodHRwczovL3Bmend3LmF1ZGtlbm5pLmlzOjQ0My9zc28vb2F1dGgyL3JlYWxtcy9yb290L3JlYWxtcy9hdWRrZW5uaSIsInRva2VuTmFtZSI6ImFjY2Vzc190b2tlbiIsInRva2VuX3R5cGUiOiJCZWFyZXIiLCJhdXRoR3JhbnRJZCI6IjJKRUtmcFREcV9HVE5QOWMxalhQdUthaUJYMCIsImF1ZCI6Im15Q2liYUNsaWVudElkIiwibmJmIjoxNjExMTQ5NzAwLCJncmFudF90eXBlIjoidXJuOm9wZW5pZDpwYXJhbXM6Z3JhbnQtdHlwZTpjaWJhIiwic2NvcGUiOlsiUkVMQVRFRFBBUlRZOk15T3duQ2xpZW50Iiwic2lnbmF0dXJlIiwib3BlbmlkIiwicHJvZmlsZSJdLCJhdXRoX3RpbWUiOjE2MTExNDk3MDAsInJlYWxtIjoiL2F1ZGtlbm5pIiwiZXhwIjoxNjExMTUzMzAwLCJpYXQiOjE2MTExNDk3MDAsImV4cGlyZXNfaW4iOjM2MDAsImp0aSI6IldmdDFvbmpfMGlqblNrTms2TnBjdUcwX0VEbyJ9.m9MZw1VvtvH9UwH1GvV1Y7posi4TX23qve7V7ZzOn7k", "scope": "openid profile signature RELATEDPAR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NpUsGD7dyFnkE900GI0MXdAQc4tm19vMNH4k8DZkpLiE7dNBuwbTA", "token_type": "Bearer", "expires_in": 3599 }

 

Example of the payload in Access token

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 { "sub": "10935f1e-2688-4f9c-80d2-3fb45241522c", "cts": "OAUTH2_STATELESS_GRANT", "auth_level": 0, "auditTrackingId": "ed977018-9c1c-4037-ad58-c61dc22480a8-1172709", "subname": "10935f1e-2688-4f9c-80d2-3fb45241522c", "iss": "https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni", "tokenName": "access_token", "token_type": "Bearer", "authGrantId": "2JEKfpTDq_GTNP9c1jXPuKaiBX0", "aud": "myCibaClientId", "nbf": 1611149700, "grant_type": "urn:openid:params:grant-type:ciba", "scope": [ "RELATEDPARTY:MyOwnClient", "signature", "openid", "profile" ], "auth_time": 1611149700, "realm": "/audkenni", "exp": 1611153300, "iat": 1611149700, "expires_in": 3600, "jti": "Wft1onj_0ijnSkNk6NpcuG0_EDo" }

 

Example of the payload in Id token

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 { "at_hash": "HS346_RrLjYdBWM0kz9iig", "sub": "10935f1e-2688-4f9c-80d2-3fb45241522c", "signature": "GKW/CmGmNJ1/p7EMPxQuoE/WQ/nQf5FuVHkjgPpCwOsdkfjU45S57SAH/nKevPP6to3+Mfr2WhZePd5NOf1s8SivFDn4dBSbe92n1HpUYhH7sXgyDR+IlWUmFw0CKKQ2hkYRMU7fW1TCKzQxs30m9vik6XkfcQisIIEdWUU5eP3oi+HF5HHZ8GzSGa23oA39t56+Gz+TIUH6G3OevIJv7xQgl8cJd+ZwlUtvQQQbRwZVdmC4ZFQ+rfW7h3TCmZqbBuO9CQnOWYAmx9vkynEyaVbkt89/cy2D5YRBjgiT87j7fJv89a5K05EMPgF/eeCNOSoCGFS0H01Y5FIRAL/nkpOI0EA==", "auditTrackingId": "ed977018-9c1c-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kenni", "tokenName": "id_token", "aud": "myCibaClientId", "documentNr": "na", "nationalRegisterId": "1406714889", "azp": "myCibaClientId", "auth_time": 1611149700, "name": "Einar Helgi Hrafnsson", "realm": "/audkenni", "exp": 1611153300, "tokenType": "JWTToken", "iat": 1611149700 }

 

 

 

Step 4

 

Step 4: (Userinfo)

Here we ask for the users info using the Access token as Authorization header parameter.

To get the Userinfo we send a POST call to following URI:
https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/userinfo

Parameters needed in call

We need to add following header parameter

  • Token (Bearer, using the Access token from last call as value)

 

CURL example of the call

1 2 3 curl --location --request POST 'https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/userinfo' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT05FIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiIxMDkwNWYxZS0yNjA4LTRmOWMtODBkMi0zZmI0NTI0MTUyMmMiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiZWQ5NzcwMTgtOWMxYy00MDM3LWFkNTgtYzYxZGMyMjQ4MGE4LTExNDk2NjUiLCJpc3MiOiJodHRwczovL3Bmend3LmF1ZGtlbm5pLmlzOjQ0My9zc28vb2F1dGgyL3JlYWxtcy9yb290L3JlYWxtcy9hdWRrZW5uaSIsInRva2VuTmFtZSI6ImFjY2Vzc190b2tlbiIsInRva2VuX3R5cGUiOiJCZWFyZXIiLCJhdXRoR3JhbnRJZCI6Inc5eUpXem1fMU04TGJqenplUnJQOUp3anZzSSIsImF1ZCI6Im15Q2liYUNsaWVudElkIiwibmJmIjoxNjExMTQzNDYzLCJncmFudF90eXBlIjoidXJuOm9wZW5pZDpwYXJhbXM6Z3JhbnQtdHlwZTpjaWJhIiwic2NvcGUiOlsiUkVMQVRFRFBBUlRZOk15T3duQ2xpZW50Iiwic2lnbmF0dXJlIiwib3BlbmlkIiwicHJvZmlsZSJdLCJhdXRoX3RpbWUiOjE2MTExNDM0NjMsInJlYWxtIjoiL2F1ZGtlbm5pIiwiZXhwIjoxNjExMTQ3MDYzLCJpYXQiOjE2MTExNDM0NjMsImV4cGlyZXNfaW4iOjM2MDAsImp0aSI6ImFqNzJuR0Y4ZElyclU2TFlZSlNhSjJ0bDNXNCJ9.3tGtHPYYN-ImdiPDj8JIQYFwqR_2VrjARo4FDWshbZ8'

 

C# - RestSharp example of the call

1 2 3 4 5 6 7 var client = new RestClient("https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/userinfo"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT05FIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiIxMDkwNWYxZS0yNjA4LTRmOWMtODBkMi0zZmI0NTI0MTUyMmMiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiZWQ5NzcwMTgtOWMxYy00MDM3LWFkNTgtYzYxZGMyMjQ4MGE4LTExNDk2NjUiLCJpc3MiOiJodHRwczovL3Bmend3LmF1ZGtlbm5pLmlzOjQ0My9zc28vb2F1dGgyL3JlYWxtcy9yb290L3JlYWxtcy9hdWRrZW5uaSIsInRva2VuTmFtZSI6ImFjY2Vzc190b2tlbiIsInRva2VuX3R5cGUiOiJCZWFyZXIiLCJhdXRoR3JhbnRJZCI6Inc5eUpXem1fMU04TGJqenplUnJQOUp3anZzSSIsImF1ZCI6Im15Q2liYUNsaWVudElkIiwibmJmIjoxNjExMTQzNDYzLCJncmFudF90eXBlIjoidXJuOm9wZW5pZDpwYXJhbXM6Z3JhbnQtdHlwZTpjaWJhIiwic2NvcGUiOlsiUkVMQVRFRFBBUlRZOk15T3duQ2xpZW50Iiwic2lnbmF0dXJlIiwib3BlbmlkIiwicHJvZmlsZSJdLCJhdXRoX3RpbWUiOjE2MTExNDM0NjMsInJlYWxtIjoiL2F1ZGtlbm5pIiwiZXhwIjoxNjExMTQ3MDYzLCJpYXQiOjE2MTExNDM0NjMsImV4cGlyZXNfaW4iOjM2MDAsImp0aSI6ImFqNzJuR0Y4ZElyclU2TFlZSlNhSjJ0bDNXNCJ9.3tGtHPYYN-ImdiPDj8JIQYFwqR_2VrjARo4FDWshbZ8"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

 

 

Step 4: Expected response

The answer from this call should give you a PKCS1 Signature and a signing certificate. The same signature and certificate as is in the Id token from last step.

The REST API service answer is in JSON format.

Best practice

Best practice is to verify the signature and the certificate. Verify the user’s info in answer against the certificate. By decoding the signature using the certificate you should end up with the hash from the earlier step.

The response should include following

  • signature (PKCS1)

  • documentNr (should be “na”)

  • certificate (signing certificate)

  • nationalRegisterId (The social id number of the user)

  • name (The users name)

  • sub (A unique Id of the user in our system)

  • subname (A unique Id of the user in our system)

Example of answer from step 4

1 2 3 4 5 6 7 8 9 { "signature": "GKW/CmGmNJ1/p7EMPxQuoE/WQ/nQfGfusIe3i8jgPpCwOphUS57SAH/nKevPP6to3+Mfr2WhZePd5NOf1E/SivFDn4dBSbe92n1HpUYhH7sXgyDR+IlWUmFw0CKKQ2hkYRMU7fW1TCKzQxs30m9vik6XkfcQisIIEdWUU5eP3oi+HF5HHZ8GzSGa23oA39t56+Gz+TIUH6G3OevIJv7xQgl8cJd+ZwlUtvQQQbRwZVdmC4ZFQ+rfW7h3TCmZqbBuO9CQnOWYAmx9vkynEyaVbkt89/cy2D5YRBjgiT87j7fJv89a5K05EMPgF/eeCNOSoCGFS0H01Y5FIRAL/nkpOI0EA==", "documentNr": "na", "certificate": "MIIF3zCCBMegAwIBAgIDHwFeMA0GCSEWeioKus3DQEBCwUAMH4xCzAJBgNVBAYTAklTMRM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llRoaXMgY2VydGlmaWNhdGUgaXMgaW50ZW5kZWQgZm9yIHNpZ25pbmcuIFRoaXMgY2VydGlmaWNhdGUgaXMgaXNzdWVkIGFzIGEgcXVhbGlmaWVkIGNlcnRpZmljYXRlIGluIGFjY29yZGFuY2Ugd2l0aCBhY3QgMjgvMjAwMSBhbmQgRGlyZWN0aXZlIDk5LzkzL0VDLjA1BggrBgEFBQcCARYpaHR0cDovL2NwLmF1ZGtlbm5pLmlzL2Z1bGxnaWx0YXVka2VubmkvY3AwIgYIKwYBBQUHAQMEFjAUMAgGBgQAjkYBATAIBgYEAI5GAQQwDgYDVR0PAQH/BAQDAgZAMB8GA1UdIwQYMBaAFMIpPob/hsTaNR9ppqT/AYM8SjOpMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuYXVka2VubmkuaXMvZnVsbGdpbHRhdWRrZW5uaS9sYXRlc3QuY3JsMB0GA1UdDgQWBBTsNlPXW2i2ssZ2tdnQpK51DYEEPDANBgkqhkiG9w0BAQsFAAOCAQEAt/oz8Hza2SVdJEfQ8541oDACXcyM3W66IP+89MLre8lZPPVTHa4TXBAix2Pj6CDmdyPfyZS/btqLZmuAPviRF7pZ6e/RLKuOl5UUg3x7kEu+p/3pKb+J8fcpdIzOT7l+OCwV8m3rPSe98TOkvZYR63t1Nl7JONQ/cVsS7kJAeyL2K+vkt9XCRse5NmC2UM743l4vGYePQDriyDgSXYXkbAPKbhtIsuQY9xT0GdCLqg9sK0G06LsKK1FQ4LVS/iH8Tb2YuvReO6k6mVoxK84C7A0h9xeUMcJVjXHYpSeMoW7xRPTHpeyLVF+4rD2my1009naTMAMPoUEwr8s2Cn61Og==", "nationalRegisterId": "1406714889", "name": "Einar Helgi Hrafnsson", "sub": "10935f1e-2638-4f9c-80d2-3fb45241522c", "subname": "10935f1e-2638-4f9c-80d2-3fb45241522c" }