Skip to main content

Client Initialization (T102)

Initialize your EFRIS client by retrieving the server's public key and encrypted client private key. This endpoint establishes the cryptographic foundation for secure communication and does not require prior authentication.


Endpoint Overview

PropertyValue
Interface CodeT102
Request Encrypted❌ No
Response Encrypted❌ No
Request Body{ "otp": "100983" } (optional)
Response FormatJSON

Flow Description

  1. Client requests the RSA private key for the registered device.
  2. Server verifies that tin matches deviceNo and device status is normal.
  3. Server retrieves the device's private key, encrypts it via white-box encryption, and returns clientPriKey + keyTable.
  4. Client stores the encrypted credentials for subsequent decryption operations.

🔐 Security Note: The clientPriKey is encrypted using white-box cryptography. Store keyTable securely—it is required to decrypt the private key locally.


try {
// Call T102: Client Initialization
// Optional: pass OTP if required by your deployment
$response = $client->clientInit(['otp' => '100983']);

$content = $response['data']['content'] ?? $response;

if (isset($content['serverPubKey'], $content['clientPriKey'], $content['keyTable'])) {
echo "✅ Initialization successful\n";
echo " Server PubKey: " . substr($content['serverPubKey'], 0, 30) . "...\n";

// Store credentials securely for later use
$keyClient->setClientPrivateKey($content['clientPriKey']);
$keyClient->setKeyTable($content['keyTable']);
$keyClient->setServerPublicKey($content['serverPubKey']);
} else {
echo "⚠️ Missing required keys in response\n";
}
} catch (\UraEfrisSdk\Exceptions\APIException $e) {
echo "❌ API Error: " . $e->getMessage() . "\n";
echo " Return Code: " . $e->getReturnCode() . "\n";
}

Response Structure

{
"data": {
"content": {
"clientPriKey": "vovhW9PY7YUPA98X36BSM8V1OA3gSyF+nTNWAeiVsXMIc",
"serverPubKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQ...",
"keyTable": "OiJ2b3ZoVzlQWTdZVVBBOThYMzZCU004VjFPQTN..."
}
},
"globalInfo": {
"interfaceCode": "T102",
"returnStateInfo": {
"returnCode": "00",
"returnMessage": "SUCCESS"
}
}
}

Response Fields

FieldRequiredTypeDescription
clientPriKey✅ YesStringEncrypted client RSA private key (white-box). Used to decrypt server responses. Only available when appId is AP01.
serverPubKey✅ YesStringServer's RSA public key. Used to verify signatures on server responses.
keyTable✅ YesStringWhite-box decryption table. Required to decrypt clientPriKey locally.

Return Codes

CodeMessageDescription
00SUCCESSInitialization completed; keys returned
99Unknown errorGeneric server error
06The outer message is emptyMalformed request envelope
07GlobalInfo content cannot be emptyMissing required globalInfo
11InterfaceCode cannot be emptyMissing interfaceCode in request
400Device does not existdeviceNo not registered for this TIN
401Device key does not existNo cryptographic key found for device
402Device key expiredDevice credentials have expired
403Device status is abnormalDevice is blocked, suspended, or inactive

💡 Tip: Call this endpoint once per session after verifying time sync (T101). Cache the returned keys securely—do not re-fetch on every API call.


Common Use Cases

  1. Session Bootstrap
    Establish cryptographic context before calling authenticated endpoints like T103: Sign In.

  2. Key Rotation Handling
    Re-initialize when receiving 402 (key expired) to fetch updated credentials.

  3. Multi-Device Support
    Initialize separate KeyClient instances per deviceNo for taxpayers operating multiple fiscal devices.

  4. Offline Mode Preparation
    Cache serverPubKey to enable offline invoice signing when network is unavailable.