# How to create a self-signed Certificate for SharePoint Authentication via Azure AD

**URL:** <https://community.cdata.com/t/how-to-create-a-self-signed-certificate-for-sharepoint-authentication-via-azure-ad/648>\
**Category:** Data Sources\
**Tags:** article, sharepoint, certificate, oauthjwt, application-grant-flow\
**Created:** [March 1, 2024, 6:23pm UTC](https://community.cdata.com/t/how-to-create-a-self-signed-certificate-for-sharepoint-authentication-via-azure-ad/648 "2024-03-01T18:23:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedik](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/tedik/32/1647_2.png) [@tedik](https://community.cdata.com/u/tedik)\
**Post date:** [March 1, 2024, 6:23pm UTC](https://community.cdata.com/t/how-to-create-a-self-signed-certificate-for-sharepoint-authentication-via-azure-ad/648/1 "2024-03-01T18:23:01Z")

</div>

When using SharePoint Online you can define applications in Azure AD and these applications can be granted permissions to SharePoint, but also to all the other services in Office 365 ( **note** : this will not work for SharePoint On-Premise.)

1- Create an empty text file on your computer.&nbsp;  
2- Copy the _PowerShell_ script from the [Granting access via Azure AD App-Only](https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread#:~:text=copied%20from%20here%3A-,PowerShell,-Copy) page and paste it into the empty text file created.

 ![7effae90-0ae4-4637-ace9-9c1788a84c30.png](https://us1.discourse-cdn.com/cdata/original/1X/c8a60392013cda3f012d55fdd8aaa08b6ae89470.png)

3- Rename the text file _Create-SelfSignedCertificate_ and save it as a **ps1** file (_Create-SelfSignedCertificate.ps1)._&nbsp;  
4- Open _Windows PowerShell_ as _ **Administrator** _ inside the folder where this file is saved.&nbsp;  
5- Copy the [PowerShell](https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread#:~:text=with%20this%20script%3A-,PowerShell,-Copy) command from the above-mentioned page:

_.\Create-SelfSignedCertificate.ps1 -CommonName “SharepointCert” -StartDate 2023-10-09 -EndDate 2024-11-30_

- The _ **CommonName** _ value is the name of the certificate we are creating.
- Change the _ **StartDate** _ to the current date and the _ **EndDate** _ to a date of your choice.

6- Paste and run the modified command to Windows PowerShell.

 ![67c508da-3bbd-4571-919d-95c4a4ee10ec.png](https://us1.discourse-cdn.com/cdata/original/2X/f/f397c9f4cce80cf9702abba3d89ac1e3951a10df.png)

7- _Enter the password_ will prompt to protect the Private Key so set a password as you want to protect this Private key.

 ![0c4d0bcf-e5e3-455e-809c-1f648447a550.png](https://us1.discourse-cdn.com/cdata/original/2X/1/18193cf4aa6c93ba3078bdefc09df5a5c5650b99.png)

2 files will be created: _SharepointCert.pfx (private key)_ and _SharepointCert.cer (public key)_.

 ![68596cd7-4aae-4053-bebf-97e61c0fb223.png](https://us1.discourse-cdn.com/cdata/original/2X/0/013aac984214d316587d790d6c9804cd26097856.png)

 ![43e6460a-e39d-459a-9c68-939218919dc7.png](https://us1.discourse-cdn.com/cdata/original/2X/2/261a95488f3784151873a932c5d199d1500228a5.png)

Keep the private key safe. The public key is the one you need to upload to your Azure Application.
