コード例 #1
0
        protected void ValidateThumbprint(bool uploadCert)
        {
            if (X509Certificate != null)
            {
                var operationDescription = string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, X509Certificate.Thumbprint);
                if (uploadCert)
                {
                    var parameters = new ServiceCertificateCreateParameters
                    {
                        Data              = CertUtilsNewSM.GetCertificateData(X509Certificate),
                        Password          = null,
                        CertificateFormat = CertificateFormat.Pfx
                    };

                    ExecuteClientActionNewSM(
                        null,
                        CommandRuntime.ToString(),
                        () => this.ComputeClient.ServiceCertificates.Create(this.ServiceName, parameters));
                }

                CertificateThumbprint = X509Certificate.Thumbprint;
            }
            else
            {
                CertificateThumbprint = CertificateThumbprint ?? string.Empty;
            }

            ThumbprintAlgorithm = ThumbprintAlgorithm ?? string.Empty;
        }
コード例 #2
0
        private byte[] GetCertificateData()
        {
            if (((CertToDeploy is PSObject) && ((PSObject)CertToDeploy).ImmediateBaseObject is X509Certificate2) ||
                (CertToDeploy is X509Certificate2))
            {
                var cert = ((PSObject)CertToDeploy).ImmediateBaseObject as X509Certificate2;

                return(CertUtilsNewSM.GetCertificateData(cert));
            }
            else
            {
                var certPath = this.ResolvePath(CertToDeploy.ToString());
                return(CertUtilsNewSM.GetCertificateData(certPath, Password));
            }
        }
コード例 #3
0
 private byte[] GetCertificateData()
 {
     if ((CertToDeploy is PSObject) && ((PSObject)CertToDeploy).ImmediateBaseObject is X509Certificate2)
     {
         var cert = ((PSObject)CertToDeploy).ImmediateBaseObject as X509Certificate2;
         return(CertUtilsNewSM.GetCertificateData(cert));
     }
     else if (CertToDeploy is X509Certificate2)
     {
         return(CertUtilsNewSM.GetCertificateData(CertToDeploy as X509Certificate2));
     }
     else
     {
         var certPath = this.ResolvePath(CertToDeploy.ToString());
         return(File.ReadAllBytes(certPath));
     }
 }