[Dúvida] Certificado a3 chamar.
Closed this issue · 3 comments
fabiohcnobre commented
Gente estou passando o meu projeto para .net6/7 e antigamente usava
assim:
var cert = CertificadoDigitalUtils.ListareObterDoRepositorio();
Precisava algo equivalente
Obrigado.
fabiohcnobre commented
Ja consegui fazer obrigado
eduprog commented
Ja consegui fazer obrigado
Como você consegut?
Seria bom a galera saber!
fabiohcnobre commented
Por enquanto usando a mesma
public static X509Certificate2 ListareObterDoRepositorio()
{
var store = CertificadoDigital.ObterX509Store(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
var collection = store.Certificates;
var fcollection = collection.Find(X509FindType.FindByTimeValid, DateTime.Now, true);
var scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificados válidos:", "Selecione o certificado que deseja usar",
X509SelectionFlag.SingleSelection);
if (scollection.Count == 0)
{
throw new Exception("Nenhum certificado foi selecionado!");
}
store.Close();
return scollection[0];
}