Exemplo n.º 1
0
        public IFluentHpkpOptions PinCertificate(string thumbprint, StoreLocation storeLocation = StoreLocation.LocalMachine,
                                                 StoreName storeName = StoreName.My)
        {
            try
            {
                _validator.ValidateThumbprint(thumbprint);
            }
            catch (Exception e)
            {
                throw new ArgumentException(e.Message, thumbprint);
            }

            var helper = new X509Helper();
            var cert   = helper.GetCertByThumbprint(thumbprint, storeLocation, storeName);
            var pin    = helper.GetSubjectPublicKeyInfoPinValue(cert);

            cert.Reset();

            if (!_pins.Contains(pin))
            {
                _pins.Add(pin);
            }

            return(this);
        }
        public void ValidateThumbprint_ValidThumbprint_NoException()
        {
            const string thumbprint = "a0 a1 ab 90 c9 fc 84 7b 3b 12 61 e8 97 7d 5f d3 22 61 d3 cc";

            Assert.DoesNotThrow(() => _validator.ValidateThumbprint(thumbprint));
            Assert.DoesNotThrow(() => _validator.ValidateThumbprint(thumbprint.ToUpper()));
        }
Exemplo n.º 3
0
        public void ValidateThumbprint_ValidThumbprint_NoException()
        {
            const string thumbprint = "a0 a1 ab 90 c9 fc 84 7b 3b 12 61 e8 97 7d 5f d3 22 61 d3 cc";

            _validator.ValidateThumbprint(thumbprint);
            _validator.ValidateThumbprint(thumbprint.ToUpper());
        }