web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Resource (.cer file or SSL certificates) to X509Certificate object

(0) ShareShare
ReportReport
Posted on by 2,546

Hello Friends,

I have one SSL certificate file (.cer) . i have embedded in D365 fin & ops AOT using resource. But now i want to initialize the object X509Certificate using the content of resouces (.cer)

C# code is working but i am picking from local folder.

X509Certificate Cert = X509Certificate.CreateFromCertFile("C:\\Users\\Admina5a726cde9\\Documents\\visual studio 

X++ code is not working tried so many thing by using SysResouce, Bindata etc.

SysResourceType sysresouceType;
ResourceNode resourceNode;
container con;
resourceNode = SysResource::getResourceNode(resourceStr(Certificate));
System.Byte[] bytes;
Binary binary = Binary::constructFromContainer(con);
using (System.IO.MemoryStream stream = binary.getMemoryStream())
{
bytes = stream.ToArray();
}
X509Certificate certificate = new X509Certificate(bytes);

I have the same question (0)
  • Piyush Adhikari Profile Picture
    2,546 on at
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    resourceNode    resourceNode;
    Filename        fileName;
    
    resourceNode = SysResource::getResourceNode(resourcestr(TestCert));
    if (resourceNode)
    {
        resourceNode. AOTload();
        fileName =  SysResource::saveToTempFile(resourceNode);
    }
    
    X509Certificate Cert = X509Certificate.CreateFromCertFile(fileName);

    Hi Piyush,

    Did you try this as well?

  • Piyush Adhikari Profile Picture
    2,546 on at

    Though AOTload() is depreciated now ...but still i think code  should work

    but again it will use temp storage of D365 f & o cloud .. which i don't want now. i am looking for a solution where resources content will be converted directed into bytes.

    If i will not get any other solution i will this code

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Piyush,

    Where are you initializing the container object in the code you provided?

  • Piyush Adhikari Profile Picture
    2,546 on at

    Was a typing mistake

    tried both but not working

    con = SysResource::getResourceNodeData(resourceNode);

    con = SysResource::getResourceContents(resourceNode);

    i tried many ways but all were failed.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans