-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setting a FriendlyName for a Windows certificate
- Loading branch information
1 parent
1d7c96d
commit 4739967
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<# | ||
.SYNOPSIS | ||
<Overview of script> | ||
.DESCRIPTION | ||
<Brief description of script> | ||
.NOTES | ||
Version: 1.0 | ||
Author: <Name> | ||
Creation Date: <Date> | ||
Purpose/Change: Initial script development | ||
#> | ||
|
||
# Set Error Action to Stop | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Grab the script path | ||
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition | ||
echo "the current script path is $scriptPath" | ||
|
||
# these are some of the env variables that are available to you | ||
echo "PlayFab Title ID is $env:PF_TITLE_ID" # e.g. 59F84 | ||
echo "PlayFab Build ID is $env:PF_BUILD_ID" # Guid, e.g. 09d91059-22d3-4d0a-8c99-f34f80525aae | ||
echo "PlayFab Virtual Machine ID is $env:PF_VM_ID" # e.g. vmss:SouthCentralUs:2458795A9259968E_12fe54be-fae1-41aa-83d9-09b809d5ef01:09d91059-22d3-4d0a-8c99-f34f80525aae | ||
echo "Region where the VM is deployed is $env:PF_REGION" # e.g. SouthCentralUs | ||
echo "Shared content folder is $env:PF_SHARED_CONTENT_FOLDER_VM" # e.g. D:\sharedcontentfolder (All servers running on this VM have access to this folder through the PF_SHARED_CONTENT_FOLDER env variable.) | ||
|
||
# ACTION: Specify the correct subject name for your certificate | ||
$subjectName = "DC=..., O=..., OU=..., CN=..." | ||
|
||
# Find the certificate by subject name in the machine store | ||
$cert = Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object { $_.SubjectName.Name -eq $subjectName } | ||
|
||
if ($cert) { | ||
# ACTION: specify a proper friendly name for your certificate | ||
$cert.FriendlyName = "My cert friendly name" | ||
$cert | Out-Null # Suppress output | ||
Write-Host "Friendly name set to 'My cert friendly name' for the certificate with subject name: $subjectName" | ||
} else { | ||
Write-Host "Certificate with subject name '$subjectName' not found." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Windows - set certificate with friendly name | ||
|
||
Sometimes our game server code needs to access a certificate by its friendly name. The friendly name property is a Windows only property which is not guaranteed to be present when PlayFab copies the cert into the VM. However, sometimes we cannot change the game server code to reference the certificate with more standard methods (e.g. Subject, Thumbprint, etc). This script helps you set the friendly name of a certificate in the Windows certificate store. | ||
|
||
**NOTE**: Script is applicable only to PlayFab Builds using Windows processes. In this case, certs are deployed to the local machine store of the VM so the VmStartupScript can access them and set the friendly name. If you are running Builds using Windows containers, you can use a similar script on your StartGameCommand (before you start your game server). |