Create userPFXCertificate with Javabeta lib

Antoine Lo 0 Reputation points
2024-10-02T15:59:35.55+00:00

Hello all,

I am trying to import a certificate/private key with userPFXCertificate using the Graph API Beta Java library to add this feature to our PKI product.

The code sample in the documentation page (Create UserPFXCertificate) seemed pretty straightforward. I adapted it for Java. But I have no luck and the error message does not have any detail on the error.

I have created a dedicated Intune trusted certificate profile, a PKCS certificate profile

Here the produced JSON body, I have anonymised or truncated some of the values:

{ 
   "createdDateTime":"2024-10-02T14:52:55.997567041Z",
"encryptedPfxBlob":"MIIRzwIBAzCCEYgGCSqGSIb3DQEHAaCCEXkEghF1MIIRc...MAkGBSsOAwIaBQAEFJ5jjPNAiya0dvPEfAu75jlL23fPBBTNgCjXLxyVNDZSETwM/2RNKWUeNAIDAYag",
   "encryptedPfxPassword":"SdeVjSGbnMbGclpPBdUsGAS1A9ZDZnGYQ26oO+Id4...l4uTsY4HSsCM26umLF5q1fhi1kzrFvTnXd70AEyopdTk84TpztAph9+pcWaA==",
   "expirationDateTime":"2032-03-06T09:04:48Z",
   "intendedPurpose":"smimeEncryption",
   "keyName":"<NAME OF THE INTUNE TRUSTED CERTIFICATE PROFILE>",
   "lastModifiedDateTime":"2024-10-02T14:52:55.99760599Z",
   "paddingScheme":"oaepSha256",
   "providerName":"<NAME OF OUR PROVIDER>",
   "startDateTime":"2022-03-09T09:04:48Z",
   "thumbprint":"iSsIpYjk64QAZEQW2e/Wuv2jN3g=",
   "userPrincipalName":"<USER UPN>" // is this supposed to be an email address ?
}

The error message:

http status: 400

com.microsoft.graph.beta.models.odataerrors.ODataError: {  "_version": 3,  "Message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 5a0de11e-aa87-4c8b-9f5d-XXXXXXX1137 - Url: https://fef.amsub0502.manage.microsoft.com/RACerts/StatelessImportPFXService/XXXXXXXX-ffff-XXXX-XXXX-092622171078/deviceManagement/userPfxCertificates?api-version=5022-06-22",  "CustomApiErrorPhrase": "",  "RetryAfter": null,  "ErrorSourceService": "",  "HttpHeaders": "{}"}

Using the UserPFXCertificate list works fine so I think it is not a configuration problem.

Any idea ?

Thanks in advance !

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,351 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
5,237 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xenia-MSFT 2,825 Reputation points Microsoft Vendor
    2024-10-03T02:34:15.9866667+00:00

    @Antoine Lo Thanks for posting in our Q&A.

    Honestly, I'm not familiar with Java. For this issue, it seems more related to develop scope. With Q&A limitation resource, it is suggested to create an online support ticket to get more help. Here is the support link:

    https://video2.skills-academy.com/en-us/mem/get-support

    Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.