Add-AzVpnClientRootCertificate
語法
Default (預設值)
Add-AzVpnClientRootCertificate
-VpnClientRootCertificateName <String>
-VirtualNetworkGatewayName <String>
-ResourceGroupName <String>
-PublicCertData <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
Add-AzVpnClientRootCertificate Cmdlet 會將根憑證新增至虛擬網路閘道。
根憑證是識別根憑證授權單位的 X.509 憑證。
根據設計,閘道上使用的所有憑證都信任根憑證。
此 Cmdlet 會將現有的憑證指派為閘道根憑證。
如果您沒有可用的 X.509 憑證,您可以透過公開金鑰基礎結構產生憑證,或使用憑證產生器 (例如 makecert.exe)。
若要新增根憑證,您必須指定憑證名稱,並提供憑證的純文字表示法 (如需詳細資訊,請參閱 PublicCertData 參數)。
Azure 可讓您將多個根憑證指派給閘道。
多個根憑證通常由包含來自多個公司的使用者的組織部署。
範例
範例 1:將用戶端根憑證新增至虛擬閘道
$Text = Get-Content -Path "C:\Azure\Certificates\ExportedCertificate.cer"
$CertificateText = for ($i=1; $i -lt $Text.Length -1 ; $i++){$Text[$i]}
Add-AzVpnClientRootCertificate -PublicCertData $CertificateText -ResourceGroupName "ContosoResourceGroup" -VirtualNetworkGatewayName "ContosoVirtualGateway" -VpnClientRootCertificateName "ContosoClientRootCertificate"
此範例會將用戶端根憑證新增至名為 ContosoVirtualGateway 的虛擬閘道。
第一個命令會使用 Get-Content Cmdlet 來取得先前匯出的根憑證文字表示法,並將該文字資料儲存為名為 $Text 的變數。
然後,第二個命令使用 for 迴圈來提取除第一行和最後一行之外的所有文字。
擷取的文字儲存在名為 $CertificateText 的變數中。
然後,第三個命令會使用儲存在 $CertificateText 中的文字搭配 Add-AzVpnClientRootCertificate Cmdlet,將根憑證新增至閘道。
參數
-DefaultProfile
用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-PublicCertData
指定要新增之根憑證的文字表示法。
若要取得文字表示法,請以.cer格式 (使用 Base64 編碼) 匯出憑證,然後在文字編輯器中開啟產生的檔案。
當您執行此操作時,您會看到類似以下的輸出(請注意,實際輸出將包含比此處顯示的縮寫示例更多的文本行):----- BEGIN CERTIFICATE ----- MIIC13FAAXC3671Auij9HHgUNEW8343NMJklo09982CVVFAw8w ----- END CERTIFICATE ----- PublicCertData 由檔案中第一行(----- BEGIN CERTIFICATE -----)和最後一行(----- END CERTIFICATE -----)之間的所有行組成。
您可以使用類似下列的 Windows PowerShell 命令來擷取此資料: $Text = Get-Content -Path "C:\Azure\Certificates\ExportedCertificate.cer"$CertificateText = for ($i=1; $i -lt $Text.Length -1 ; $i++){$Text\[$i\]}
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-ResourceGroupName
指定指派根憑證的資源群組名稱。
資源群組會分類專案,以協助簡化清查管理和一般 Azure 系統管理。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-VirtualNetworkGatewayName
指定新增憑證的虛擬網路閘道名稱。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-VpnClientRootCertificateName
指定此 Cmdlet 新增的用戶端根憑證名稱。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 資源名稱 |
參數集
(All)
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸出