Beispiel #1
0
        public virtual AlibabaCloudCredentials GetRsaKeyPairAlibabaCloudCredential()
        {
            if (String.IsNullOrEmpty(this.publicKeyId) || String.IsNullOrEmpty(this.privateKeyFile) || String.IsNullOrEmpty(this.regionId))
            {
                throw new ClientException("Missing required variable option for 'default Client'");
            }
            RsaKeyPairCredential         rsaKeyPairCredential = new RsaKeyPairCredential(this.publicKeyId, this.privateKeyFile);
            DefaultProfile               profile           = DefaultProfile.GetProfile(this.regionId, this.publicKeyId, this.privateKeyFile);
            RsaKeyPairCredentialProvider provider          = new RsaKeyPairCredentialProvider(rsaKeyPairCredential, profile);
            BasicSessionCredentials      basicCrededential = (BasicSessionCredentials)provider.GetCredentials();

            return(basicCrededential);
        }
Beispiel #2
0
        public virtual AlibabaCloudCredentials GetRsaKeyPairAlibabaCloudCredential()
        {
            if (String.IsNullOrEmpty(publicKeyId) || String.IsNullOrEmpty(privateKeyFile) || String.IsNullOrEmpty(regionId))
            {
                throw new ClientException("Missing required variable option for 'default Client'");
            }
            var rsaKeyPairCredential = new KeyPairCredentials(publicKeyId, privateKeyFile);
            var profile = DefaultProfile.GetProfile(regionId, publicKeyId, privateKeyFile);

            RsaKeyPairCredentialProvider rsaKeyPairCredentialProvider;

            if (null != alibabaCloudCredentialProvider)
            {
                rsaKeyPairCredentialProvider = (RsaKeyPairCredentialProvider)alibabaCloudCredentialProvider;
            }
            else
            {
                rsaKeyPairCredentialProvider = new RsaKeyPairCredentialProvider(rsaKeyPairCredential, profile);
            }

            return(rsaKeyPairCredentialProvider.GetCredentials());
        }