Ejemplo n.º 1
0
        }                            // for test

        public EncryptionManager(EncryptionLevel level, TrustStrategy strategy, ILogger logger)
        {
            _encryptionLevel = level;

            if (_encryptionLevel == EncryptionLevel.Encrypted)
            {
                switch (strategy)
                {
                case V1.TrustStrategy.TrustAllCertificates:
                    TrustStrategy = new TrustAllCertificates(logger);
                    break;

                case V1.TrustStrategy.TrustSystemCaSignedCertificates:
                    TrustStrategy = new TrustSystemCaSignedCertificates(logger);
                    break;

                default:
                    throw new InvalidOperationException($"Unknown trust strategy: {strategy}");
                }
            }
        }
        public EncryptionManager(EncryptionLevel level, TrustStrategy strategy, ILogger logger)
        {
            _encryptionLevel = level;

            if (_encryptionLevel != EncryptionLevel.None)
            {
                switch (strategy.ServerTrustStrategy())
                {
                case V1.TrustStrategy.Strategy.TrustOnFirstUse:
                    TrustStrategy = new TrustOnFirstUse(logger, strategy.FileName());
                    break;

                case V1.TrustStrategy.Strategy.TrustSystemCaSignedCertificates:
                    TrustStrategy = new TrustSystemCaSignedCertificates(logger);
                    break;

                default:
                    throw new InvalidOperationException($"Unknown trust strategy: {strategy}");
                }
            }
        }