Renew SSL Certificate in D365fo in x++

 Renew SSL Certificate in D365fo in x++

Reference Link:

https://ax.docentric.com/expired-certificates-renewal-in-d365fo/


Step 1: Identify Expired Certificates

Start Windows PowerShell as administrator and enter the following two commands:


cd cert:\LocalMachine\My

ls | Select-Object NotAfter,Thumbprint,Subject | Where-Object -Property Subject -like "CN=DeploymentsOnebox.*" | Sort-Object -Property Subject,NotAfter


You will get the list of certificates, required by D365FO:





The NotAfter column shows when each of them expires. The Subject column contains descriptive information about certificates. The Thumbprint column contains the key by which the certificate is recognized by the operating system.


In the image above you can see, that all four certificates have already expired.


Step 2: Clone Expired Certificates and Extend Their Validitys

For each of the four certificates repeat the following commands:


$Thumbprint = (get-childitem -Path 01F93A5974A14DC3B40F1CF0BE78127974187BE5 )

New-SelfSignedCertificate -CloneCert $Thumbprint -NotAfter (Get-Date).AddMonths(120)


Replace

01F93A5974A14DC3B40F1CF0BE78127974187BE5

with the thumbprint of the certificate you want to clone.





You’ll get a new self-signed certificate valid for 10 years, cloned from the existing one, with its new thumbprint:




Step 3: Update D365FO’s Config Files

To see the new list of certificates run the following command in PowerShell:


ls | Select-Object NotAfter,Thumbprint,Subject | Where-Object -Property Subject -like "CN=DeploymentsOnebox.*" | Sort-Object -Property Subject,NotAfter





Now you see two certificates for each of the certificate types – one with the old validity and thumbprint and one with the new validity (current date + 120 months) and thumbprint.


Now start Visual Studio as administrator and open the following three files in the C:\AOSService\webroot folder:


web.config

wif.config

wif.services.config

Press Ctrl+Shift+H key combination to open Find and Replace dialog. Make sure that you select All Open Documents in the Look in drop-down selection box, so that find and replace action will be applied on all three open files.


Now you will have to repeat the following actions for each pair of certificate types:


In the Find what box enter the thumbnail of the old (expired) certificate.

In the Replace with box enter the thumbnail of the cloned new certificate.

Replace all the occurrences in open files.








After you have done this for all four certificates, save the three config files and close Visual Studio.

Restart your browser and navigate to D365FO. It should start without any problems.



Solution 2:

1.

New-SelfSignedCertificate -Subject "CN=*.cloud.onebox.dynamics.com,O=Microsoft Corporation,L=Redmond,S=WA,C=US" -DnsName "*.cloud.onebox.dynamics.com", "usnconeboxax1ecom.cloud.onebox.dynamics.com", "usnconeboxax1pos.cloud.onebox.dynamics.com", "usnconeboxax1ret.cloud.onebox.dynamics.com" -CertStoreLocation "cert:\LocalMachine\My" -KeyUsage DataEncipherment, KeyEncipherment, DigitalSignature -HashAlgorithm "SHA384" -KeyAlgorithm RSA -KeyLength 2048 -NotAfter (Get-Date).AddYears(5)

2.

Copy the certificates from personal certificates and paste them into trusted certificates in the computer certificate.

3.

And bind IIS with new certificate



Comments

Popular posts from this blog

D365FO – AX – X++ –Refresh, Reread, Research, and ExecuteQuery

Create Inventory Journal through Code in D365FO X++

SalesLine Reservation in D365fo x++