private void GetPrivateKeys(RMSTrustedPublishingDomain oldDefaultTPD, string slcCertChainCompressed)
        {
            if (oldDefaultTPD == null || string.IsNullOrEmpty(oldDefaultTPD.PrivateKey) || this.HasCryptoModeChanged(oldDefaultTPD, slcCertChainCompressed))
            {
                this.resealKey   = false;
                this.privateKeys = SharedServerBoxRacIdentityGenerator.EmptyPrivateKeys;
                return;
            }
            this.privateKeys = new Dictionary <string, PrivateKeyInformation>(1, StringComparer.OrdinalIgnoreCase);
            PrivateKeyInformation privateKeyInformation = new PrivateKeyInformation(oldDefaultTPD.KeyId, oldDefaultTPD.KeyIdType, oldDefaultTPD.KeyContainerName, oldDefaultTPD.KeyNumber, oldDefaultTPD.CSPName, oldDefaultTPD.CSPType, oldDefaultTPD.PrivateKey, false);

            this.privateKeys.Add(privateKeyInformation.Identity, privateKeyInformation);
            this.resealKey = true;
        }
Beispiel #2
0
        private TrustedPublishingDomainPrivateKeyProvider CreateKeyProviderAndDkmProtectKey(string tpdName, KeyInformation keyInfo, SecureString tpdFilePassword, out string dkmEncryptedPrivateKey, out object failureTarget)
        {
            failureTarget = null;
            byte[]           bytes            = this.DecryptPrivateKey(keyInfo, tpdFilePassword);
            ExchangeGroupKey exchangeGroupKey = new ExchangeGroupKey(null, "Microsoft Exchange DKM");
            Exception        ex;

            if (!exchangeGroupKey.TryByteArrayToEncryptedString(bytes, out dkmEncryptedPrivateKey, out ex))
            {
                failureTarget = tpdName;
                throw new FailedToDkmProtectPrivateKeyException(ex);
            }
            Dictionary <string, PrivateKeyInformation> dictionary = new Dictionary <string, PrivateKeyInformation>(1, StringComparer.OrdinalIgnoreCase);
            PrivateKeyInformation privateKeyInformation           = new PrivateKeyInformation(keyInfo.strID, keyInfo.strIDType, keyInfo.strKeyContainerName, keyInfo.nKeyNumber, keyInfo.strCSPName, keyInfo.nCSPType, dkmEncryptedPrivateKey, true);

            dictionary.Add(privateKeyInformation.Identity, privateKeyInformation);
            return(new TrustedPublishingDomainPrivateKeyProvider(null, dictionary));
        }