{"id":7486,"date":"2020-08-26T04:30:51","date_gmt":"2020-08-26T04:30:51","guid":{"rendered":"http:\/\/blogs.aaddevsup.xyz\/?p=7486"},"modified":"2023-03-15T20:39:12","modified_gmt":"2023-03-15T20:39:12","slug":"using-powershell-to-configure-a-signing-certificate-for-a-saml-based-sso-enterprise-application","status":"publish","type":"post","link":"https:\/\/blogs.aaddevsup.xyz\/2020\/08\/using-powershell-to-configure-a-signing-certificate-for-a-saml-based-sso-enterprise-application\/","title":{"rendered":"Using PowerShell to configure a signing certificate for a SAML-based SSO Enterprise Application"},"content":{"rendered":"\n

In my last<\/a> blog post I talked about how to use PowerShell to instantiate an MSAL Confidential Client Application<\/a> to acquire an access token using Client Credentials Grant<\/a> flow. In this post we will use PowerShell to instantiate an MSAL Public Client Application<\/a> to perform an Authorization Code Grant<\/a> flow to obtain a delegated permission Access Token for Microsoft Graph. We will then use that access token to call Microsoft Graph to configure a signing certificate for our SAML Application Service Principal. Just a quick refresher that a certificate is always required when setting up SAML Sigle Sign-On feature for an Enterprise App in Azure AD.<\/p>\n\n\n\n

Pre-requisites<\/h3>\n\n\n\n

To run the script in this blog you should have the following:<\/p>\n\n\n\n

1) A SAML-based SSO Enterprise Application you want to configure a signing certificate for. Get the Object ID of this Application in the Properties blade of the Enterprise App<\/strong> – we will need it for the script. The script in this blog performs the same thing as doing the following UI action in the portal:<\/p>\n\n\n\n

Azure Active Directory -> Enterprise Application -> Pick the correct App -> Single sign-on -> click ‘Edit’ link in the SAML Signing Certificate section -> Import Certificate<\/p>\n\n\n\n

\"\"<\/div>\n\n\n\n
\n\n\n\n

If you are trying to automate a SAML-based SSO Application, take a look at the documentation Automate SAML-based SSO app configuration with Microsoft Graph API<\/a>. This blog can help with step 4, Configure Signing Certifcate, of that article.<\/p>\n\n\n\n

2) An app registration to sign in a user and get an access token for Microsoft Graph. Get the Application (client) ID of this app in the Overview section<\/strong> – we will need it for the script. This application should have the following App Registration configuration:<\/p>\n\n\n\n

Supported account types<\/td>Accounts in this organizational directory only<\/td><\/tr>
Redirect URIs<\/td>http:\/\/localhost under ‘Mobile and desktop applications’ platform<\/td><\/tr>
API permissions<\/td>Microsoft Graph – Delegated permissions: Application.ReadWrite.All<\/strong> and User.Read<\/strong>
(Make sure you grant Admin consent to these permissions)
<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

3) The user who logs in to get the MS Graph Access Token should be one of the following Azure AD Administrative Role – this is required in order to make a change to the Service Principal:<\/p>\n\n\n\n