When connecting to event hub storage AccessKey with + character causing Illegal base64 character

Renan Berenger 1 Reputation point
2022-10-13T21:39:58.027+00:00

I have a spring boot app using camel to connect to Azure event hub.
I can publish events to Azure event hub but when I try to consume it fails with the following error.

2022-10-13 18:30:40 WARN o.a.c.c.a.e.EventHubsConsumer - Error processing exchange. Exchange[]. Caused by: [java.lang.IllegalArgumentException - Illegal base64 character 20]
java.lang.IllegalArgumentException: Illegal base64 character 20
at java.util.Base64$Decoder.decode0(Base64.java:714)
at java.util.Base64$Decoder.decode(Base64.java:526)
at java.util.Base64$Decoder.decode(Base64.java:549)
at com.azure.storage.common.implementation.StorageImplUtils.computeHMac256(StorageImplUtils.java:203)
at com.azure.storage.common.StorageSharedKeyCredential.generateAuthorizationHeader(StorageSharedKeyCredential.java:129)
at com.azure.storage.common.policy.StorageSharedKeyCredentialPolicy.process(StorageSharedKeyCredentialPolicy.java:38)
at com.azure.core.http.HttpPipelineNextPolicy.process(HttpPipelineNextPolicy.java:46)
at com.azure.storage.common.policy.MetadataValidationPolicy.process(MetadataValidationPolicy.java:48)
at com.azure.core.http.HttpPipelineNextPolicy.process(HttpPipelineNextPolicy.java:46)
at com.azure.core.http.policy.AddDatePolicy.lambda$process$0(AddDatePolicy.java:29)
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
at reactor.core.publisher.MonoDelaySubscription.accept(MonoDelaySubscription.java:53)
at reactor.core.publisher.MonoDelaySubscription.accept(MonoDelaySubscription.java:34)
at reactor.core.publisher.FluxDelaySubscription$DelaySubscriptionOtherSubscriber.onNext(FluxDelaySubscription.java:131)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.propagateDelay(MonoDelay.java:271)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:286)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

I can see the storage access key has + character and this character is replaced with space which causes this exception.
For example:
Before: AOwXNuCr6RLNnOWr0V0P1Qn2XZTLhDcBCZiWSiGNAtuigJorkv5UJLpHq6N9c43Ga+thjY2un/t6+AStJ1U2vQ==
After: AOwXNuCr6RLNnOWr0V0P1Qn2XZTLhDcBCZiWSiGNAtuigJorkv5UJLpHq6N9c43Ga thjY2un/t6 AStJ1U2vQ==

I tried to replace character with %2B but it didn't work. Is it a bug with Camel library for Azure or Azure itself?

I'm using camel-azure-eventhubs-starter version 3.14.5.

Thanks

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
546 questions
{count} votes

2 answers

Sort by: Most helpful
  1. BhargavaGunnam-MSFT 25,156 Reputation points Microsoft Employee
    2022-10-14T18:39:53.627+00:00

    Hello @Renan Berenger ,

    Welcome to the MS Q&A platform.

    Please correct me if my understanding is wrong. You have an app that connects to the Azure event hub using the event hub connection string and publishes events to the Azure event hub. While consuming the events via the camel library, you see the error message.

    Illegal base64 character 20 means that the received value contained an invalid character not present in the Base64 alphabet. 20 is a space because the error message uses hex format.

    The issue seems like with the Camel library during the conversion of Base64.

    I hope this helps.


  2. Renan Berenger 1 Reputation point
    2022-10-18T01:24:38.477+00:00

    Hi, yes I did. Thanks for the answer.
    I was able to make it work using custom bean or kafka component instead of event hub camel component so you are probably right.

    Thanks.