How to select User Digital Certificate in Web applications?

5

I'm developing an ASP.NET MVC5 project to demonstrate electronic invoices.

During the process of searching for notes, manifestation or download, I access the webservice of the Internal Revenue Service and I need to send the digital certificate regarding the CNPJ.

Everything works fine while I'm developing and testing things locally, but when the application is published and goes to the server I can no longer select the digital certificate I want to use.

I'm using the X509Certificate2 , X509Store and X509Certificate2Collection

I would like to do something like this link: link

When I click on the image of the digital certificate, the Store containing the certificates is opened, but I can only do this when I start the local application. After I go to the server, I can not access the Store.

Has anyone ever worked with this or know how to solve the problem?

    
asked by anonymous 30.12.2015 / 13:57

3 answers

1

Good afternoon Jefferson, on the site that you indicated only the public key of the certificate is sent to the server, to sign the NF-e and the private key is required.

When I implemented NF-e I did a webservice and a local desktop application that downloaded the XML, signed it, sent it to the recipe server, and relayed the result to the webservice. I still think the best strategy.

If you need to use the site you will have to use the A1 model and directly reference the certificate file.

I hope I have helped.

    
30.03.2016 / 18:55
0

Configure your IIS to "Require Digital Certificates," so the server will ask for the clients certificate. Whether it is A3 or A1 certified.

On this question the folks have already explained how to do this: How to request the IIS 7.5 client ssl certificate

    
17.05.2016 / 21:33
0

I did this using A1

private RecepcaoEvento.RecepcaoEventoSoapClient _nfeRecepcao;
    _nfeRecepcao.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySerialNumber, GetSerialCertificado());
     private string GetSerialCertificado()
            {
                X509Store store = new X509Store("My");
                store.Open(OpenFlags.ReadOnly);
                foreach (var certificado in store.Certificates)
                {
                    if (certificado.SubjectName.Name.Contains(cnpj))
                    {
                        _serialCertificado = certificado.SerialNumber;
                    }
                }
                store.Close();
                return _serialCertificado;
            }

So far, it's working in several places this way.

    
09.01.2017 / 18:45