diff --git a/src/ResourceManager/ApiManagement/Commands.ApiManagement/Helpers/Extensions.cs b/src/ResourceManager/ApiManagement/Commands.ApiManagement/Helpers/Extensions.cs index 0a4f0debb592..7823b3abd130 100644 --- a/src/ResourceManager/ApiManagement/Commands.ApiManagement/Helpers/Extensions.cs +++ b/src/ResourceManager/ApiManagement/Commands.ApiManagement/Helpers/Extensions.cs @@ -30,6 +30,7 @@ public static HostnameConfiguration GetHostnameConfiguration( var hostnameConfiguration = new HostnameConfiguration( Mappers.MapHostnameType(hostnameConfig.HostnameType), hostnameConfig.Hostname); + if (!string.IsNullOrWhiteSpace(hostnameConfig.EncodedCertificate)) { hostnameConfiguration.EncodedCertificate = hostnameConfig.EncodedCertificate; @@ -55,6 +56,11 @@ public static HostnameConfiguration GetHostnameConfiguration( hostnameConfiguration.NegotiateClientCertificate = hostnameConfig.NegotiateClientCertificate.Value; } + if (hostnameConfig.CertificateInformation != null && hostnameConfig.EncodedCertificate == null) + { + hostnameConfiguration.Certificate = hostnameConfig.CertificateInformation.ToCertificateInformation(); + } + return hostnameConfiguration; } @@ -78,5 +84,20 @@ public static CertificateConfiguration GetCertificateConfiguration(this PsApiMan return certificateConfiguration; } + + public static CertificateInformation ToCertificateInformation(this PsApiManagementCertificateInformation psCertificate) + { + if (psCertificate == null) + { + return null; + } + + var certificateInformation = new CertificateInformation(); + certificateInformation.Thumbprint = psCertificate.Thumbprint; + certificateInformation.Expiry = psCertificate.Expiry; + certificateInformation.Subject = psCertificate.Subject; + + return certificateInformation; + } } }