-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
When using the Azure SDK to update an Azure Directory Applications, the SDK seems to not encode correctly the certificate given as parameter with withPublicKey() retrieve from X509Certificate.getEncoded(). Submitting as a PEM directly is also not possible because the SDK does internally convert to Base64.
Exception or Stack Trace
"{"error":{"code":"Request_BadRequest","message":"Cannot convert the literal 'XXX' to the expected type 'Edm.Binary'.","innerError":{"date":"2026-03-02T20:44:14","request-id":"XXX","client-request-id":"XXX"}}}"
Code Snippet
var application = azureResourceManager.accessManagement() .activeDirectoryApplications() .getByName(applicationId);
X509Certificate x509Cert = read from somewhere
update.defineCertificateCredential(certificateName) .withAsymmetricX509Certificate() .withPublicKey(x509Cert.getEncoded()) .withStartDate(startDate) .withDuration(java.time.Duration.ofDays(durationInMonths * 30L)) .attach();