When we are developing High Trust Provider Hosted Add-ins, we will be using a self-signed certificate for Add-in Authentication. However in production we will have to use a third party provided trusted certificate and self-signed certificate is not really an option. Once we have created the self signed certificate, we can refer that during Provider Hosted Add-in Creation.However we also have to add the Issue ID generated using the certificate. In this blog we will see how to create the Issuer ID using the self signed certificate.

Spin up SharePoint 2016 Management Shell.Run the below command that will create the issuer ID and register a Secure Token Issuer using the Self Signed Certificate and the Issuer ID.
- #
- Create an Issuer ID
- $issuerID = [System.Guid]::NewGuid().ToString()# Get registered Issuer Name
- $oSite = Get - SPSite "http://sharepoint2016"
- $oSPrealm = Get - SPAuthenticationRealm - ServiceContext $oSite
- $IssuerName = $issuerID + '@' + $oSPrealm# Get Certificate
- $Certificate = Get - PfxCertificate "C:\Users\farmaccount\Documents\Certificate\Add-inCertificate.cer"#
- Register Token Issuer
- $SecurityTokenIssuer = New - SPTrustedSecurityTokenIssuer - Name $issuerID - RegisteredIssuerName $IssuerName - Certificate $Certificate - IsTrustBroker# Choose to turn off HTTPS
- for dev environment
- $SPSTokenServiceConfig = Get - SPSecuritytokenServiceConfig
- $SPSTokenServiceConfig.AllowOAuthOverHttp = $true
- $SPSTokenServiceConfig.Update()# Run an IISRESET
- IISRESET# Print the Issuer ID
- write - host "Issuer ID:"
- $issuerID
![# Create an Issuer ID $issuerID = [System.Guid]::NewGuid().ToString()# Get registered Issuer Name $oSite = Get - SPSite "http://sharepoint2016" $oSPrealm = Get - SPAuthenticationRealm - ServiceContext $oSite $IssuerName = $issuerID + '@' + $oSPrealm# Get Certificate $Certificate = Get - PfxCertificate "C:\Users\farmaccount\Documents\Certificate\Add-inCertificate.cer"# Register Token Issuer $SecurityTokenIssuer = New - SPTrustedSecurityTokenIssuer - Name $issuerID - RegisteredIssuerName $IssuerName - Certificate $Certificate - IsTrustBroker# Choose to turn off HTTPS for dev environment $SPSTokenServiceConfig = Get - SPSecuritytokenServiceConfig $SPSTokenServiceConfig.AllowOAuthOverHttp = $true $SPSTokenServiceConfig.Update()# Run an IISRESET IISRESET# Print the Issuer ID write - host "Issuer ID:" $issuerID](https://cdn.c-sharpcorner.com/uploadfile/blogimages/10032016191546pm/image002.webp)
Thus we have obtained the issuer ID which is highlighted in red as shown below.
![# Create an Issuer ID $issuerID = [System.Guid]::NewGuid().ToString()# Get registered Issuer Name $oSite = Get - SPSite "http://sharepoint2016" $oSPrealm = Get - SPAuthenticationRealm - ServiceContext $oSite $IssuerName = $issuerID + '@' + $oSPrealm# Get Certificate $Certificate = Get - PfxCertificate "C:\Users\farmaccount\Documents\Certificate\Add-inCertificate.cer"# Register Token Issuer $SecurityTokenIssuer = New - SPTrustedSecurityTokenIssuer - Name $issuerID - RegisteredIssuerName $IssuerName - Certificate $Certificate - IsTrustBroker# Choose to turn off HTTPS for dev environment $SPSTokenServiceConfig = Get - SPSecuritytokenServiceConfig $SPSTokenServiceConfig.AllowOAuthOverHttp = $true $SPSTokenServiceConfig.Update()# Run an IISRESET IISRESET# Print the Issuer ID write - host "Issuer ID:" $issuerID](https://cdn.c-sharpcorner.com/uploadfile/blogimages/10032016191546pm/image003.webp)
We will be using the issuer id - 2eaf9497-dea3-46b9-a429-21e01b8f6d44 while developing the Provider Hosted Add-in.
![# Create an Issuer ID $issuerID = [System.Guid]::NewGuid().ToString()# Get registered Issuer Name $oSite = Get - SPSite "http://sharepoint2016" $oSPrealm = Get - SPAuthenticationRealm - ServiceContext $oSite $IssuerName = $issuerID + '@' + $oSPrealm# Get Certificate $Certificate = Get - PfxCertificate "C:\Users\farmaccount\Documents\Certificate\Add-inCertificate.cer"# Register Token Issuer $SecurityTokenIssuer = New - SPTrustedSecurityTokenIssuer - Name $issuerID - RegisteredIssuerName $IssuerName - Certificate $Certificate - IsTrustBroker# Choose to turn off HTTPS for dev environment $SPSTokenServiceConfig = Get - SPSecuritytokenServiceConfig $SPSTokenServiceConfig.AllowOAuthOverHttp = $true $SPSTokenServiceConfig.Update()# Run an IISRESET IISRESET# Print the Issuer ID write - host "Issuer ID:" $issuerID](https://cdn.c-sharpcorner.com/uploadfile/blogimages/10032016191546pm/image004.webp)
If you have forgotten the issuer id which was created earlier, we can get it by running the command ‘Get-SPTrustedSecurityTokenIssuer’. We can reuse the certificate and issuer ID for creating multiple Provider Hosted Add-ins.
Summary - Thus we saw how to create an Issuer ID for use with Provider Hosted Add-in in SharePoint Server 2016.
harry devuPosted Apr 6, 2018, 2:12 AM
Hi, I have created self signed certificate to host provider hosted app in sharepoint online.How can we get issue id of self signed certificate as i don't have sharepoint 2016 management shell. Is there any option to get issuer ID for certificate?
Humayun Kabir MamunPosted Oct 13, 2016, 4:42 AM
Nice...