tomasmcguinness / dotnet-passbook

A .Net Library for generating Apple Passbook (Wallet) files for iOS. Please get involved by creating pull requests and opening issues!
MIT License
316 stars 116 forks source link

Getting System.Security.Cryptography.CryptographicException when iam trying to generate a PKPass file #169

Closed Mazhar9797 closed 2 years ago

Mazhar9797 commented 2 years ago

An exception of type 'System.Security.Cryptography.CryptographicException' occurred and was caught. Message : Keyset does not exist Source : System.Security Data : System.Collections.ListDictionaryInternal TargetSite : CMSG_SIGNER_ENCODE_INFO CreateSignerEncodeInfo(System.Security.Cryptography.Pkcs.CmsSigner, Boolean, System.Security.Cryptography.SafeCryptProvHandle ByRef)

When i test it in my machine it works fine but when moved to Server its giving this error.

Below is the code iam using: request.CertThumbprint = "xxxx" request.CertLocation = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine;

            var pkPassCert = "yyyy"
            if (pkPassCert.Contains("~"))
            {
                pkPassCert = System.Web.HttpContext.Current.Server.MapPath(pkPassCert);
            }
            var wwdrcert = File.ReadAllBytes(pkPassCert); 
            request.AppleWWDRCACertificate = wwdrcert;

            request.Style = PassStyle.EventTicket;

            generatedPass = generator.Generate(request);
tomasmcguinness commented 2 years ago

So you're using IIS for hosting your code?

Mazhar9797 commented 2 years ago

yes ....the code is moved through the Azure devops pipeline

tomasmcguinness commented 2 years ago

Is it deployed to a virtual machine or similar in Azure?

The latest version of dotnet-passbook no longer uses CertThumbprint and CertLocation because of issues like these.

Can you create an instance of an X509Certificate using your own pass (like you do with the WWDR certificate?

Mazhar9797 commented 2 years ago

Sorry my bad we got it resolved buy giving the IIS_IUSRS required permissions in the Private key section , before we had tried with the wrong user. Thanks for ur support One more think wanted to know is there any way using which we can view the generated pass (PkPass file) in WINDOWS machine ?, have checked online tools but cudnt find one

tomasmcguinness commented 2 years ago

No, not I know of, sorry. A web visualiser is something that might be very useful.