diff --git a/hub/hub_service.bal b/hub/hub_service.bal index 8da7e1f..94d1084 100644 --- a/hub/hub_service.bal +++ b/hub/hub_service.bal @@ -221,7 +221,9 @@ service object { if (message.hubSecret is string) { string hubSecret = message.hubSecret; string encryptionKey = config:HUB_SECRET_ENCRYPTION_KEY; + log:printInfo("Encryption key", encryptionKey = encryptionKey); byte[] encryptionKeyInBytes = (config:HUB_SECRET_ENCRYPTION_KEY_FORMAT).equalsIgnoreCaseAscii("base64-encoded-bytes") ? (check array:fromBase64(encryptionKey)) : encryptionKey.toBytes(); + log:printInfo("Encryption key in bytes", encryptionKeyInBytes = encryptionKeyInBytes); byte[16] initialVector = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; foreach int i in 0...15 { initialVector[i] = (check random:createIntInRange(0, 255)); diff --git a/hub/start_hub.bal b/hub/start_hub.bal index 22d1e32..9ceb247 100644 --- a/hub/start_hub.bal +++ b/hub/start_hub.bal @@ -198,12 +198,15 @@ function startMissingSubscribers(websubhub:VerifiedSubscription[] persistedSubsc kafka:Consumer consumerEp = check conn:createMessageConsumer(topicName, consumerGroup); if (subscriber.hubSecret is string && (subscriber.hubSecret).startsWith(config:ENCRYPTED_SECRET_PREFIX) && (subscriber.hubSecret).endsWith(config:ENCRYPTED_SECRET_SUFFIX)) { string hubSecretWithPattern = subscriber.hubSecret; + log:printInfo("Hubsecret before decryption", hubSecret = hubSecretWithPattern); string hubSecret = hubSecretWithPattern.substring((config:ENCRYPTED_SECRET_PREFIX).length(), hubSecretWithPattern.length() - (config:ENCRYPTED_SECRET_SUFFIX).length()); byte[] ivAppendedCipherText = check array:fromBase64(hubSecret); int cipherLength = ivAppendedCipherText.length(); byte[] cipher = ivAppendedCipherText.slice(0, cipherLength-16); byte[] iv = ivAppendedCipherText.slice(cipherLength-16, cipherLength); string encryptionKey = config:HUB_SECRET_ENCRYPTION_KEY; + log:printInfo("Encryption key", encryptionKey = encryptionKey); + log:printInfo("Encryption key in bytes", encryptionKeyInBytes = encryptionKey.toBytes()); byte[] plainText = check crypto:decryptAesGcm(cipher, encryptionKey.toBytes(), iv); subscriber.hubSecret = check string:fromBytes(plainText); log:printInfo("Decrypted the hubSecret", topic = subscriber.hubTopic);