Esempio n. 1
0
        private static void UpdateResultFromFile(UInt160 hash)
        {
            string           address = hash.ToAddress();
            X509Certificate2 cert;

            try
            {
                cert = new X509Certificate2(Path.Combine(Settings.Default.Paths.CertCache, $"{address}.cer"));
            }
            catch (CryptographicException)
            {
                results[hash].Type = CertificateQueryResultType.Missing;
                return;
            }
            if (cert.PublicKey.Oid.Value != "1.2.840.10045.2.1")
            {
                results[hash].Type = CertificateQueryResultType.Missing;
                return;
            }
            if (!hash.Equals(Contract.CreateSignatureRedeemScript(ECPoint.DecodePoint(cert.PublicKey.EncodedKeyValue.RawData, ECCurve.Secp256r1)).ToScriptHash()))
            {
                results[hash].Type = CertificateQueryResultType.Missing;
                return;
            }
            using (X509Chain chain = new X509Chain())
            {
                results[hash].Certificate = cert;
                if (chain.Build(cert))
                {
                    results[hash].Type = CertificateQueryResultType.Good;
                }
                else if (chain.ChainStatus.Length == 1 && chain.ChainStatus[0].Status == X509ChainStatusFlags.NotTimeValid)
                {
                    results[hash].Type = CertificateQueryResultType.Expired;
                }
                else
                {
                    results[hash].Type = CertificateQueryResultType.Invalid;
                }
            }
        }
Esempio n. 2
0
 public WalletAccount GetAccount(ECPoint pubkey)
 {
     return(GetAccount(Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash()));
 }
Esempio n. 3
0
 public static CertificateQueryResult Query(ECPoint pubkey)
 {
     return(Query(Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash()));
 }