Exemple #1
0
        public CertificateContext Clone()
        {
            var clone = new CertificateContext
            {
                Type       = Type,
                Thumbprint = Thumbprint,
                FilePath   = FilePath,
                DataBuffer = DataBuffer?.ToArray(),
                Password   = Password?.Copy()
            };

            switch (Type)
            {
            case ContextType.Thumbprint:
                clone.Certificate = CertificateUtilities.GetClientCertificateFromStore(Thumbprint);
                break;

            case ContextType.File:
                clone.Certificate = CertificateUtilities.GetClientCertificateFromFile(FilePath, Password);
                break;

            case ContextType.Data:
                clone.Certificate = CertificateUtilities.GetClientCertificateFromDataBuffer(DataBuffer, Password);
                break;

            default:
                throw new SafeguardDotNetException(
                          $"Error calling Clone() on unknown CertificateContext type: {Enum.GetName(typeof(ContextType), Type)}");
            }

            return(clone);
        }
Exemple #2
0
 public CertificateContext(IEnumerable <byte> data, SecureString password)
 {
     Type        = ContextType.Data;
     DataBuffer  = data.ToArray();
     Password    = password;
     Certificate = CertificateUtilities.GetClientCertificateFromDataBuffer(DataBuffer, Password);
 }