A while ago I posted a PowerShell script that I use to register a self-signed certificate that started out like this:
If you’ve tried creating a provider hosted app for SharePoint 2013 on-prem (not in Office 365) you know you likely need to go through some gyrations to set it up for high trust using the server-to-server (S2S) protocol. There’s a great article on MSDN that walks you through the details of this (linked below), but it’s a pain to have to type all that. Hopefully Visual Studio 2012’s SharePoint 2013 & Office 2013 Developer Tools will make our lives easier when we get to RTM, but for now in Beta 2 / Preview, I find it to be a pain.
That script required you to create & export the self-signed certificate (.cer) and associated private key (.pfx) using IIS. I always intended to script out the whole thing with Windows PowerShell… and now it’s finally done. Here’s what I added to the script:
Update (December, 20, 2014): I finally got around to updating my scripts… I deleted the old script I had here on my site & have added the following two. The first one will create a self-signed certificate which you can use in your local dev. The second one will set up an STS for S2S.
This generates the following…

PowerShell Results
You can see from the first line in the screenshot what you need to pass in to get this to work. If you look at the header in the script you’ll see a list of all the parameters and sample values. The script also lets you specify the certificate to use rather than letting it create one for you.

Microsoft MVP, Full-Stack Developer & Chief Course Artisan - Voitanos LLC.
Andrew Connell is a full stack developer who focuses on Microsoft Azure & Microsoft 365. He’s a 20+ year recipient of Microsoft’s MVP award and has helped thousands of developers through the various courses he’s authored & taught. Whether it’s an introduction to the entire ecosystem, or a deep dive into a specific software, his resources, tools, and support help web developers become experts in the Microsoft 365 ecosystem, so they can become irreplaceable in their organization.