protected override void ProcessRecord() { var certificates = CmdletHelpers.GetCertificates(this.ResourcesClient, this.WebsitesClient, ResourceGroupName, Thumbprint); var output = new List <PSCertificate>(); foreach (var certificate in certificates) { output.Add(new PSCertificate(certificate)); } WriteObject(certificates); }
public override void ExecuteCmdlet() { var certificates = CmdletHelpers.GetCertificates(this.ResourcesClient, this.WebsitesClient, ResourceGroupName, ThumbPrint); if (certificates.Length > 0) { if (this.ShouldProcess(this.ThumbPrint, string.Format($"Removing an App service certificate with thumbprint '{ThumbPrint}'"))) { //var certName = !string.IsNullOrEmpty(HostName) ? HostName : certificates[0].Name; try { WebsitesClient.RemoveCertificate(ResourceGroupName, certificates[0].Name); } catch (DefaultErrorResponseException e) { throw e; } } } }
protected override void ProcessRecord() { base.ProcessRecord(); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.RemovingWebAppSSLBinding, Name), Properties.Resources.RemoveWebAppSSLBinding, Name, () => { var webapp = WebsitesClient.GetWebApp(resourceGroupName, webAppName, slot); var hostNameSslStates = CmdletHelpers.GetHostNameSslStatesFromSiteResponse(webapp, Name).ToList(); if (hostNameSslStates.Count > 0) { var thumbprint = hostNameSslStates[0].Thumbprint; WebsitesClient.UpdateHostNameSslState(resourceGroupName, webAppName, slot, webapp.Location, Name, SslState.Disabled, null); if (!DeleteCertificate.HasValue || DeleteCertificate.Value) { var certificateResourceGroup = CmdletHelpers.GetResourceGroupFromResourceId(webapp.ServerFarmId); var certificates = CmdletHelpers.GetCertificates(this.ResourcesClient, this.WebsitesClient, certificateResourceGroup, thumbprint); if (certificates.Length > 0) { try { WebsitesClient.RemoveCertificate(certificateResourceGroup, certificates[0].Name); } catch (CloudException e) { // This exception is thrown when there are other Ssl bindings using this certificate. Let's swallow it and continue. if (e.Response.StatusCode != HttpStatusCode.Conflict) { throw; } } } } } }); }
protected override void ProcessRecord() { WriteObject(CmdletHelpers.GetCertificates(this.ResourcesClient, this.WebsitesClient, ResourceGroupName, Thumbprint)); }