@@ -5,7 +5,7 @@ $subscriptionId = $parameters['subscriptionId']
55$resourceGroupName = $parameters [' resourceGroupName' ]
66$virtualNetworkName = $parameters [' virtualNetworkName' ]
77$certificateNamePrefix = $parameters [' certificateNamePrefix' ]
8- $clientCertificatePassword = $parameters [' clientCertificatePassword' ]
8+ $clientCertificatePassword = $parameters [' clientCertificatePassword' ] # used only when certificates are created using openssl
99
1010if ($clientCertificatePassword -eq ' ' -or ($null -eq $clientCertificatePassword )) {
1111 $clientCertificatePassword = ' S0m3Str0nGP@ssw0rd'
@@ -197,7 +197,10 @@ function CreateCerificateOpenSsl() {
197197 ipsec pki -- gen -- outform pem > " $ ( $dn ) Key.pem"
198198 ipsec pki -- pub - -in " $ ( $dn ) Key.pem" -- outform pem > " $ ( $dn ) PubKey.pem"
199199 ipsec pki -- issue - -in " $ ( $dn ) PubKey.pem" -- cacert caCert.pem -- cakey caKey.pem -- dn " CN=$ ( $dn ) " -- san $dn -- flag clientAuth -- outform pem > " $ ( $dn ) Cert.pem"
200+
200201 openssl pkcs12 -in " $ ( $dn ) Cert.pem" - inkey " $ ( $dn ) Key.pem" - certfile caCert.pem - export - out " $ ( $dn ) .p12" - password " pass:$ ( $clientCertificatePassword ) "
202+ # openssl pkcs12 -in "$($dn).p12" -password "pass:$($clientCertificatePassword)" -nocerts -out "$($dn)PrivateKey.pem" -nodes
203+ # openssl pkcs12 -in "$($dn).p12" -password "pass:$($clientCertificatePassword)" -nokeys -out "$($dn)PublicCert.pem" -nodes
201204
202205 $publicRootCertData = openssl x509 -in caCert.pem - outform pem
203206 $publicRootCertData = $publicRootCertData -replace " -----BEGIN CERTIFICATE-----" , " "
@@ -239,6 +242,8 @@ If ($false -eq $subnets.Contains($gatewaySubnetName)) {
239242}
240243else {
241244 Write-Host " The subnet $gatewaySubnetName exists in the virtual network." - ForegroundColor Green
245+ $gatewaySubnet = Get-AzVirtualNetworkSubnetConfig - Name $gatewaySubnetName - VirtualNetwork $virtualNetwork
246+ $gatewaySubnetPrefix = $gatewaySubnet.AddressPrefix [0 ]
242247}
243248
244249$vpnClientAddressPoolPrefix = CalculateVpnClientAddressPoolPrefix $gatewaySubnetPrefix
0 commit comments