Skip to content

Commit 3fb9fc3

Browse files
authored
Merge pull request #2684 from vinatara/dev
Changes for end to end ssl and SSLPolicy in application gateways
2 parents 3ea6aef + 57969e3 commit 3fb9fc3

File tree

41 files changed

+5906
-2068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5906
-2068
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.0.4-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
70-
<Reference Include="Microsoft.Azure.Management.Network, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
71-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.5.0.1-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
70+
<Reference Include="Microsoft.Azure.Management.Network">
71+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
7272
<Private>True</Private>
7373
</Reference>
7474
<Reference Include="Microsoft.Azure.Management.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

src/ResourceManager/Compute/Commands.Compute.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Azure.Graph.RBAC" version="3.1.0-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.Compute" version="13.0.4-prerelease" targetFramework="net45" />
10-
<package id="Microsoft.Azure.Management.Network" version="5.0.1-preview" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.Network" version="6.0.2-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.Framework" version="1.0.6052.28118-prerelease" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.0.4-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
8181
<Private>True</Private>
8282
</Reference>
83-
<Reference Include="Microsoft.Azure.Management.Network, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
84-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.5.0.1-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
83+
<Reference Include="Microsoft.Azure.Management.Network">
84+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
8585
<Private>True</Private>
8686
</Reference>
8787
<Reference Include="Microsoft.Azure.Management.Storage">

src/ResourceManager/Compute/Commands.Compute/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Compute" version="13.0.4-prerelease" targetFramework="net45" />
12-
<package id="Microsoft.Azure.Management.Network" version="5.0.1-preview" targetFramework="net45" />
12+
<package id="Microsoft.Azure.Management.Network" version="6.0.2-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Management.Storage" version="4.1.0-preview" targetFramework="net45" />
1414
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1515
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
<Reference Include="Microsoft.Azure.Management.Authorization">
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6565
</Reference>
66-
<Reference Include="Microsoft.Azure.Management.Network, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.5.0.1-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
66+
<Reference Include="Microsoft.Azure.Management.Network">
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
7070
<Reference Include="Microsoft.Azure.ResourceManager">
@@ -183,6 +183,9 @@
183183
<None Include="ScenarioTests\ApplicationGatewayTests.ps1">
184184
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
185185
</None>
186+
<None Include="ScenarioTests\Data\ApplicationGatewayAuthCert.cer">
187+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
188+
</None>
186189
<None Include="ScenarioTests\Common.ps1">
187190
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
188191
</None>

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ApplicationGatewayTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
1516
using Microsoft.Azure.ServiceManagemenet.Common.Models;
1617
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1718
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
@@ -31,7 +32,7 @@ public ApplicationGatewayTests(ITestOutputHelper output)
3132
[Trait(Category.AcceptanceType, Category.CheckIn)]
3233
public void TestApplicationGatewayCRUD()
3334
{
34-
NetworkResourcesController.NewInstance.RunPsTest("Test-ApplicationGatewayCRUD");
35+
NetworkResourcesController.NewInstance.RunPsTest(string.Format("Test-ApplicationGatewayCRUD -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
3536
}
3637
}
3738
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ Application gateway tests
1818
#>
1919
function Test-ApplicationGatewayCRUD
2020
{
21+
param
22+
(
23+
$basedir = ".\"
24+
)
25+
2126
# Setup
2227

2328
$rglocation = Get-ProviderLocation ResourceManagement
@@ -45,7 +50,8 @@ function Test-ApplicationGatewayCRUD
4550
$rule02Name = Get-ResourceName
4651
$nic01Name = Get-ResourceName
4752
$nic02Name = Get-ResourceName
48-
53+
$authCertName = Get-ResourceName
54+
4955
try
5056
{
5157
# Create the resource group
@@ -80,8 +86,10 @@ function Test-ApplicationGatewayCRUD
8086
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name  -Port 80
8187
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name  -Port 8080
8288

89+
$authCertFilePath = $basedir + "\ScenarioTests\Data\ApplicationGatewayAuthCert.cer"
90+
$authcert01 = New-AzureRmApplicationGatewayAuthenticationCertificate -Name $authCertName -CertificateFile $authCertFilePath
8391
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
84-
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol Http -CookieBasedAffinity Enabled
92+
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 443 -Protocol Https -CookieBasedAffinity Enabled -AuthenticationCertificates $authcert01
8593

8694
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol Http -FrontendIPConfiguration $fipconfig01 -FrontendPort $fp01
8795
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol Http -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp02
@@ -90,9 +98,11 @@ function Test-ApplicationGatewayCRUD
9098
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -BackendHttpSettings $poolSetting02 -HttpListener $listener02 -BackendAddressPool $pool
9199

92100
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2
101+
102+
$sslPolicy = New-AzureRmApplicationGatewaySslPolicy -DisabledSslProtocols TLSv1_0, TLSv1_1
93103

94104
# Create Application Gateway
95-
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool, $nicPool -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01, $fipconfig02  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RequestRoutingRules $rule01, $rule02 -Sku $sku
105+
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool, $nicPool -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01, $fipconfig02  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RequestRoutingRules $rule01, $rule02 -Sku $sku -SslPolicy $sslPolicy -AuthenticationCertificates $authcert01
96106

97107
# Get Application Gateway
98108
$getgw =  Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.ApplicationGatewayTests/TestApplicationGatewayCRUD.json

Lines changed: 2966 additions & 1301 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Graph.RBAC" version="3.1.0-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.Network" version="5.0.1-preview" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.Network" version="6.0.2-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Test.Framework" version="1.0.6052.28118-prerelease" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />

src/ResourceManager/Network/Commands.Network/ApplicationGateway/ApplicationGatewayChildResourceHelper.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
8686
}
8787
}
8888

89+
// Normalize AuthenticationCertificates
90+
if (applicationGateway.AuthenticationCertificates != null)
91+
{
92+
foreach (var authCertificate in applicationGateway.AuthenticationCertificates)
93+
{
94+
authCertificate.Id = string.Empty;
95+
}
96+
}
97+
8998
// Normalize FrontendIpConfiguration
9099
if (applicationGateway.FrontendIPConfigurations != null)
91100
{
@@ -136,6 +145,16 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
136145
applicationGateway.ResourceGroupName,
137146
applicationGateway.Name);
138147
}
148+
if (null != backendHttpSettings.AuthenticationCertificates)
149+
{
150+
foreach (var authCert in backendHttpSettings.AuthenticationCertificates)
151+
{
152+
authCert.Id = NormalizeApplicationGatewayNameChildResourceIds(
153+
authCert.Id,
154+
applicationGateway.ResourceGroupName,
155+
applicationGateway.Name);
156+
}
157+
}
139158
}
140159
}
141160

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Models;
16+
using System;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
20+
namespace Microsoft.Azure.Commands.Network
21+
{
22+
[Cmdlet(VerbsCommon.Add, "AzureRmApplicationGatewayAuthenticationCertificate", SupportsShouldProcess = true),
23+
OutputType(typeof(PSApplicationGateway))]
24+
public class AddAzureApplicationGatewayAuthenticationCertificateCommand : AzureApplicationGatewayAuthenticationCertificateBase
25+
{
26+
[Parameter(
27+
Mandatory = true,
28+
ValueFromPipeline = true,
29+
HelpMessage = "The applicationGateway")]
30+
public PSApplicationGateway ApplicationGateway { get; set; }
31+
32+
public override void ExecuteCmdlet()
33+
{
34+
base.ExecuteCmdlet();
35+
36+
if (ShouldProcess(Name, Microsoft.Azure.Commands.Network.Properties.Resources.CreatingResourceMessage))
37+
{
38+
var authCertificate = this.ApplicationGateway.AuthenticationCertificates.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
39+
40+
if (authCertificate != null)
41+
{
42+
throw new ArgumentException("Authentication certificate with the specified name already exists");
43+
}
44+
45+
authCertificate = base.NewObject();
46+
this.ApplicationGateway.AuthenticationCertificates.Add(authCertificate);
47+
48+
WriteObject(this.ApplicationGateway);
49+
}
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Models;
16+
using System;
17+
using System.Management.Automation;
18+
using System.Security.Cryptography.X509Certificates;
19+
20+
namespace Microsoft.Azure.Commands.Network
21+
{
22+
public class AzureApplicationGatewayAuthenticationCertificateBase : NetworkBaseCmdlet
23+
{
24+
[Parameter(
25+
Mandatory = true,
26+
HelpMessage = "The name of the authentication certificate")]
27+
[ValidateNotNullOrEmpty]
28+
public string Name { get; set; }
29+
30+
[Parameter(
31+
Mandatory = true,
32+
HelpMessage = "Path of certificate CER file")]
33+
[ValidateNotNullOrEmpty]
34+
public string CertificateFile { get; set; }
35+
36+
public PSApplicationGatewayAuthenticationCertificate NewObject()
37+
{
38+
X509Certificate2 cert = new X509Certificate2(CertificateFile);
39+
40+
var authCertificate = new PSApplicationGatewayAuthenticationCertificate();
41+
42+
authCertificate.Name = this.Name;
43+
authCertificate.Data = Convert.ToBase64String(cert.Export(X509ContentType.Cert));
44+
authCertificate.Id =
45+
ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
46+
this.NetworkClient.NetworkManagementClient.SubscriptionId,
47+
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayAuthenticationCertificateName,
48+
this.Name);
49+
50+
return authCertificate;
51+
}
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Models;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
20+
namespace Microsoft.Azure.Commands.Network
21+
{
22+
[Cmdlet(VerbsCommon.Get, "AzureRmApplicationGatewayAuthenticationCertificate"),
23+
OutputType(typeof(PSApplicationGatewayAuthenticationCertificate), typeof(IEnumerable<PSApplicationGatewayAuthenticationCertificate>))]
24+
public class GetAzureApplicationGatewayAuthenticationCertificateCommand : NetworkBaseCmdlet
25+
{
26+
[Parameter(
27+
Mandatory = false,
28+
HelpMessage = "The name of the authentication certificate")]
29+
[ValidateNotNullOrEmpty]
30+
public string Name { get; set; }
31+
32+
[Parameter(
33+
Mandatory = true,
34+
ValueFromPipeline = true,
35+
HelpMessage = "The applicationGateway")]
36+
public PSApplicationGateway ApplicationGateway { get; set; }
37+
38+
public override void ExecuteCmdlet()
39+
{
40+
base.ExecuteCmdlet();
41+
42+
if (!string.IsNullOrEmpty(this.Name))
43+
{
44+
var authCertificate =
45+
this.ApplicationGateway.AuthenticationCertificates.First(
46+
resource =>
47+
string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));
48+
49+
WriteObject(authCertificate);
50+
}
51+
else
52+
{
53+
var authCertificates = this.ApplicationGateway.AuthenticationCertificates;
54+
WriteObject(authCertificates, true);
55+
}
56+
57+
}
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Models;
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.Network
19+
{
20+
[Cmdlet(VerbsCommon.New, "AzureRmApplicationGatewayAuthenticationCertificate", SupportsShouldProcess = true),
21+
OutputType(typeof(PSApplicationGatewayAuthenticationCertificate))]
22+
public class NewAzureApplicationGatewayAuthenticationCertificateCommand : AzureApplicationGatewayAuthenticationCertificateBase
23+
{
24+
public override void ExecuteCmdlet()
25+
{
26+
if (ShouldProcess(Name, Microsoft.Azure.Commands.Network.Properties.Resources.CreatingResourceMessage))
27+
{
28+
base.ExecuteCmdlet();
29+
WriteObject(base.NewObject());
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)