Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An exception about "The credentials supplied to the package were not recognized" #7

Closed
Elylhance opened this issue Apr 18, 2018 · 14 comments
Labels

Comments

@Elylhance
Copy link

Dear StefH

I'm developing a tls server now. I used OpenSSL-X509Certificate2-Provider to import .crt&.key, but when run to AuthenticateAsServerAsync(), an exception occurred with error message"The credentials supplied to the package were not recognized". In the other hand, it works well by converted crt&key to pfx format through openssl tool. So what's wrong here? Is the RSA private key supported? If not, i saw it in the source code.

@StefH
Copy link
Owner

StefH commented Apr 19, 2018

Please provide a code example for this, I cannot understand what you want to do.

@Elylhance
Copy link
Author

Elylhance commented Apr 23, 2018

My code like this:

 string certificateText = File.ReadAllText("certificate_pub.crt");
 string privateKeyText = File.ReadAllText("private.key");

 ICertificateProvider provider = new CertificateFromFileProvider(certificateText, privateKeyText);
 X509Certificate2 SslCertificate = provider.Certificate;

 sslClient.Sstream = new SslStream(sslClient.Nstream, false);

 await sslClient.Sstream.AuthenticateAsServerAsync(SslCertificate, iMaumutually, UserProto, false);  // A client request to connect the server, an exception is thrown,"The credentials supplied to the package were not recognized"

But it works well through the way below:
openssl pkcs12 -export -out {pfxName} -passout pass:{pfxPasswd} -inkey private.key -in certificate_pub.crt

var SslCertificate = new X509Certificate2(pfxName, pfxPasswd);

I used the same certificate.

@LamarLugli
Copy link
Contributor

are you running on .net framework or .net core? Windows or Linux?
when you create the SslCertificate object, is the HasPrivateKey property set?

@Elylhance
Copy link
Author

Elylhance commented Apr 23, 2018

Thank you for your quickly reply.
I am running on .net framework 4.5.2, windows 7 sp1. The HasPrivateKey property is not set, and the private key dose not have password

@Fumi24
Copy link

Fumi24 commented Aug 9, 2018

@Elylhance Sorry to poke this thread after months, but did you ever manage to make it work? im getting the same error and my other options i to make a custom installer and make sure openssl is installed which i kinda dont wanna do.

@StefH
Copy link
Owner

StefH commented Aug 16, 2018

@Fumi24
@Elylhance
@LammyL

Can somebody please create a full example project with dummy private/public keys. (Or the commands on how to create it) ?

Else I cannot understand what's going wrong.

@StefH
Copy link
Owner

StefH commented Aug 17, 2018

@nelsonjchen maybe you also have some ideas on this issue?

@nelsonjchen
Copy link
Contributor

Wow! That looks like my issue in #9 somewhat. Even the throw the towel in and use a PFX workaround!

@nelsonjchen
Copy link
Contributor

With #10 merged in, it would be interesting if the people experiencing this issue tried out the new constructor that'll store the key in a named container.

@StefH
Copy link
Owner

StefH commented Sep 2, 2018

@Elylhance
@LamarLugli
@Fumi24
Does merging #10 solve this issue ?

@Elylhance
Copy link
Author

Elylhance commented Sep 3, 2018

@StefH I cannot load my certificates yet with the newest NuGet packet.
Actually, it's the wolfSSL(CyaSSL)'s certificates for test.

server-cert.pem.txt
server-key.pem.txt

StefH added a commit that referenced this issue Sep 4, 2018
StefH added a commit that referenced this issue Sep 4, 2018
@StefH
Copy link
Owner

StefH commented Sep 4, 2018

@Elylhance
For the net452 example project, your server and private keys work fine?
See https://github.com/StefH/OpenSSL-X509Certificate2-Provider/blob/master/examples/ConsoleApp452/Demo.cs#L15

@Elylhance
Copy link
Author

Maybe there is some wrong with my routine, but I have no time to solve it. So just close this issue.

@StefH
Copy link
Owner

StefH commented Sep 6, 2018

OK. If you need more help in future, just create a new issue.

@StefH StefH added the question label Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants