Loxone / lxcommunicator

Communicate securily with the Loxone Miniserver via Websocket or HTTP requests
MIT License
63 stars 20 forks source link

PrivateKey #4

Closed davidwallis closed 5 years ago

davidwallis commented 5 years ago

Hi,

I'm trying to replicate similar functionality but in C# and I'm getting 401 errors when trying to do the session key - I'm thinking it might be the RSA encrption of the AES key and IV as the formatting looks the same.. Can I get my private key off my miniserver to try and decrypt the two and see if I'm sending the message correctly?

Thanks

idoodler commented 5 years ago

Hi David,

There is no possibility to get the private key from the Miniserver as this would be a security issue.

I already faced similar issues because the used Crypto Library needs the public key in another format that it is supplied by the Miniserver.

You may post the relevant code here, so we or others may help.

davidwallis commented 5 years ago

I appreciate it would be a security issue - I was fully expecting I would have to go and get it from the miniserver's sdcard.

Let me commit the code and ill post a link.

idoodler commented 5 years ago

@davidwallis3101 The private key is not accessible by any means. You need to debug it without knowing it.

davidwallis commented 5 years ago

I've just finally twigged the issue.... the RSACryptoServiceProvider in .net doesn't use PEM for the format so despite it appearing that I've loaded the public key.. I'm not..

I've now switched the the bouncycastle library and I've managed to load it.. the key being the statement above.. I need it in another format.. re-reading the code I twigged to swap Begin Certificate / End Certificate to be Begin Public Key and End Public Key.. I've now loaded it and got a http 200 back and an auth token...

I think I can now move forwards but certainly need to remove a lot of hacky code for debugging.. No doubt Ill be back with more questions :)

davidwallis commented 5 years ago

and thanks!

idoodler commented 5 years ago

I am glad to help you 👍