private static bool CanAccessPrivateKey()

in e2etest/GuestProxyAgentTest/Utilities/CertificateUtility.cs [122:144]


        private static bool CanAccessPrivateKey(X509Certificate2 cert)
        {
            if (null == cert)
            {
                return false;
            }

            try
            {
                Console.WriteLine("check cert private key, has private key: " + cert.HasPrivateKey);
                //a. Has private key doesn't mean we can access the private key (check by null != cert.PrivateKey)
                //b. PrivateKey can be get doesn't mean the information inside didn't corrupt already (check by cert.PrivateKey.KeySize > 0)
                return cert.HasPrivateKey
                       && null != cert.PrivateKey
                       && cert.PrivateKey.KeySize > 0;
            }
            catch (CryptographicException ex)
            {
                //no permission to access the certificate or privacy key
                Console.WriteLine("check cert private key error: " + ex.Message);
                return false;
            }
        }