Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public CertificateContext(IEnumerable <byte> data, SecureString password)
 {
     Type        = ContextType.Data;
     DataBuffer  = data.ToArray();
     Password    = password;
     Certificate = CertificateUtilities.GetClientCertificateFromDataBuffer(DataBuffer, Password);
 }
Exemplo n.º 3
0
 public CertificateContext(string filepath, SecureString password)
 {
     Type        = ContextType.File;
     FilePath    = filepath;
     Password    = password;
     Certificate = CertificateUtilities.GetClientCertificateFromFile(FilePath, Password);
 }
Exemplo n.º 4
0
        public CertificateContext Clone()
        {
            var clone = new CertificateContext
            {
                Thumbprint = Thumbprint,
                FilePath   = FilePath,
                Password   = Password?.Copy()
            };

            clone.Certificate = clone.Thumbprint != null
                ? CertificateUtilities.GetClientCertificateFromStore(Thumbprint)
                : CertificateUtilities.GetClientCertificateFromFile(FilePath, Password);

            return(clone);
        }
Exemplo n.º 5
0
 public CertificateContext(string thumbprint)
 {
     Type        = ContextType.Thumbprint;
     Thumbprint  = thumbprint;
     Certificate = CertificateUtilities.GetClientCertificateFromStore(Thumbprint);
 }