Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public static bool VerifyCertificateChain(ArrayList certChain, byte[] leaf)
  2. {
  3. X509Chain chain = new X509Chain();
  4. chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; // not checking revocation for now
  5.  
  6. // Here I add all offline certificates.
  7. foreach(byte[] cert in certChain)
  8. {
  9. chain.ChainPolicy.ExtraStore.Add(new X509Certificate2(cert));
  10. }
  11.  
  12. bool ret = chain.Build(new X509Certificate2(leaf));
  13.  
  14. // Always false for me.
  15. if(!ret)
  16. {
  17. // Here I get PartialChain status even though the chain is complete
  18. // since the rest of the chain is available online.
  19. foreach(X509ChainStatus status in chain.ChainStatus)
  20. {
  21. Console.WriteLine(status.ToString() + " - " + status.StatusInformation);
  22. }
  23. }
  24.  
  25. return ret;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement