geel9 / SteamAuth

A C# library that provides vital Steam Mobile Authenticator functionality
MIT License
279 stars 105 forks source link

System.Security.Cryptography.CryptographicException: Private/public key mismatch #10

Closed waylaidwanderer closed 1 year ago

waylaidwanderer commented 8 years ago

Getting this on my Ubuntu VPS when using the linkauth command from SteamBot:

Unhandled Exception:
System.Security.Cryptography.CryptographicException: Private/public key mismatch
  at Mono.Security.Cryptography.RSAManaged.ImportParameters (RSAParameters parameters) [0x00000] in <filename unknown>:0
  at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters (RSAParameters parameters) [0x00000] in <filename unknown>:0
  at SteamAuth.UserLogin.DoLogin () [0x00000] in <filename unknown>:0
  at SteamBot.Bot.<LinkMobileAuth>b__63_0 () [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Security.Cryptography.CryptographicException: Private/public key mismatch
  at Mono.Security.Cryptography.RSAManaged.ImportParameters (RSAParameters parameters) [0x00000] in <filename unknown>:0
  at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters (RSAParameters parameters) [0x00000] in <filename unknown>:0
  at SteamAuth.UserLogin.DoLogin () [0x00000] in <filename unknown>:0
  at SteamBot.Bot.<LinkMobileAuth>b__63_0 () [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0

The same command works fine on my Windows computer. Do you think it's a mono issue or something you can fix?

Edit: Found this. Looks to be a bug with mono.

shravan2x commented 8 years ago

Does this occur every time or just randomly?

waylaidwanderer commented 8 years ago

Every time for me.

shravan2x commented 8 years ago

Did you actually try the fix you linked to?

If not, replace https://github.com/geel9/SteamAuth/blob/master/SteamAuth/UserLogin.cs#L76 with var rsaParameters = new RSAParameters();

And then try again.

EDIT : I just remembered, SteamWeb.cs from SteamBot uses a very similar DoLogin method to UserLogin.cs here. And SteamWeb uses the above code, it does not ImportParameters. So this should probably fix it for you.

waylaidwanderer commented 8 years ago

I authed my bots using my local Windows computer, so I didn't bother. I'm just posting this here for other people. I'm hoping @geel9 or someone fixes it so that nobody else runs into the same issue.

shravan2x commented 8 years ago

Hmm, alright. Post back if you get a chance to test it.

ghost commented 8 years ago

Hello, I have same issue, I tested that fix and it still doesnt work. Any ideas?