Uploaded the public key (ms365-private.key) on the Microsoft Entra admin center, and I created this code.
TokenCredential credential = new ClientCertificateCredentialBuilder().tenantId("xxxxxxxx")
.clientId("xxxxxxxx")
.pemCertificate("/xxxx/xxxxx/ms365-private.key")
.build();
graphClient = new GraphServiceClient(credential);
but if i execute some methods on this graphClient , this following error occurs
[ERROR] com.azure.identity.implementation.util.CertificateUtil.performLogging - PEM certificate provided does not contain -----BEGIN CERTIFICATE-----END CERTIFICATE----- block
java.lang.IllegalArgumentException: PEM certificate provided does not contain -----BEGIN CERTIFICATE-----END CERTIFICATE----- block
at com.azure.identity.implementation.util.CertificateUtil.publicKeyFromPem(CertificateUtil.java:79)
at com.azure.identity.implementation.IdentityClientBase.getConfidentialClient(IdentityClientBase.java:196)
at com.azure.identity.implementation.IdentitySyncClient.lambda$new$2(IdentitySyncClient.java:91)
at com.azure.identity.implementation.SynchronousAccessor.getValue(SynchronousAccessor.java:45)
at com.azure.identity.implementation.IdentitySyncClient.authenticateWithConfidentialClientCache(IdentitySyncClient.java:171)
at com.azure.identity.ClientCertificateCredential.getTokenSync(ClientCertificateCredential.java:150)
at com.microsoft.kiota.authentication.AzureIdentityAccessTokenProvider.getAuthorizationToken(AzureIdentityAccessTokenProvider.java:146)
at com.microsoft.kiota.authentication.BaseBearerTokenAuthenticationProvider.authenticateRequest(BaseBearerTokenAuthenticationProvider.java:46)
I tried the following but all failed.
Change a path specify to pemCertificate() from the private key (ms365-private.key) to the public key (ms365-public.crt)
Change the format of the private key (ms365-private.key) to pem format (contains -----BEGIN CERTIFICATE-----END CERTIFICATE----- block)
I registered the app on the Microsoft Entra admin center by referring to this page:
https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http
Then I created public/private key using openssl. Here is the commands.
Uploaded the public key (ms365-private.key) on the Microsoft Entra admin center, and I created this code.
but if i execute some methods on this graphClient , this following error occurs
I tried the following but all failed.
please help.