Coder Social home page Coder Social logo

A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520) about certes HOT 8 CLOSED

fszlin avatar fszlin commented on August 16, 2024
A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520)

from certes.

Comments (8)

fszlin avatar fszlin commented on August 16, 2024 1

great, thanks for the update.

from certes.

fszlin avatar fszlin commented on August 16, 2024

Could you share the code or steps you used to generate the certificate?

from certes.

unknownguy avatar unknownguy commented on August 16, 2024

Sure. This is the part when I create the certificate:

`var csr = new CertificationRequestBuilder();

        csr.AddName("CN", domains.First());
        foreach (var alternativeName in domains.Skip(1))
            csr.SubjectAlternativeNames.Add(alternativeName);
        
        var cert = await client.NewCertificate(csr);
        
        var friendlyName = domains.First();
        friendlyName = friendlyName.Replace('.', '-');

        var password = Membership.GeneratePassword(20, 4);
        
        // Export Pfx
        var pfxBuilder = cert.ToPfx();
        var pfx = pfxBuilder.Build(friendlyName, password);

        return new CertificatePfx
        {
            Domains = domains,
            Data = pfx,
            FriendlyName = friendlyName,
            Password = password
        };`

from certes.

unknownguy avatar unknownguy commented on August 16, 2024

Sorry about closing the issue. It's been a long week with this issue.

from certes.

unknownguy avatar unknownguy commented on August 16, 2024

Then I try to import the certificate on server:

var newCert = new X509Certificate2(pfx.Data, pfx.Password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);

            if (!newCert.Verify())
            {
                //throw new Exception("Certificate is not valid!");
            }

            using (var readWriteMyStore = new X509Store(StoreName.My, StoreLocation.CurrentUser))
            {
                readWriteMyStore.Open(OpenFlags.ReadWrite);
                readWriteMyStore.Add(newCert);
                readWriteMyStore.Close();
            }

            var serverManager = new ServerManager();
            
            var site = serverManager.Sites[0];
            var binding = site.Bindings.Add(":443:" + pfx.Domains.First(), newCert.GetCertHash(), "My");
            binding.SetAttributeValue("sslFlags", 1); //enables the SNI

            serverManager.CommitChanges();

from certes.

fszlin avatar fszlin commented on August 16, 2024

Have you try installing the pfx locally into MMC? Can you export it again with private key?
What happen if you bind the SSL manually?

from certes.

unknownguy avatar unknownguy commented on August 16, 2024

I've imported the pfx using the password and worked fine. I created the biding manually and it worked fine. I exported it to another pfx with a different password if this is what you mean.

from certes.

unknownguy avatar unknownguy commented on August 16, 2024

It might have been a settings issue when I was adding the biding. With this setting it works fine:

var newCert = new X509Certificate2(pfx.Data, pfx.Password, X509KeyStorageFlags.Exportable);

and also this:

var readWriteMyStore = new X509Store(StoreName.My, StoreLocation.LocalMachine)

Now it binds with no errors and it works fine.

from certes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.