Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Credentials & Tidal
22-06-2015, 12:05 PM
Post: #1
Credentials & Tidal
Hi,

If ControlPoint has username & password for TIDAL, is it possible for Renderer to get it or does Renderer have to manage its own user/pass copy if it needs to login into Tidal itself?

I have been told it's possible if initial Get() call received by Renderer returns empty strings but when I try that with Kazoo it displays 'Tidal is disabled' message and clicking on 'Enable' does not produce anything...

Cheers,
Josef
Find all posts by this user
22-06-2015, 12:24 PM
Post: #2
RE: Credentials & Tidal
The renderer must be provided with a username & password by a control point. The renderer will store these so they only need only be provided once. There is no need for control points to store their own copy of username/password - they should instead read the username and the token generated by the login process from the renderer.

The Set action on the Credentials service should be used to set a username and password. Pass tidalhifi.com as the Id for the Tidal streaming service. Note that the password must be encrypted before being sent over the network.

If a control point wants to check whether a renderer has login details for a service, it should call Get on Credentials service, checking for a non-empty username and password being returned. (Note that the password returned is encrypted and cannot be decrypted by the control point.)
Find all posts by this user
22-06-2015, 12:42 PM (This post was last modified: 22-06-2015 12:55 PM by Josef.)
Post: #3
RE: Credentials & Tidal
Thanks for rapid answer!

>The renderer must be provided with a username & password by a control point.

How would that work with Kazoo?

I remember I entered my tidal info at some point in Kazoo (don't quite remember how and now I can't get to that dialog anymore) yet all I can see from debug log of Renderer is that Get() is called with empty strings so it seems Kazoo is asking Renderer for login details. If Renderer passes them on then indeed things proceed further as expected but if Renderer does not have login details then everything stops as described in previous post?

Addendum: I've found how to get Kazoo to ask for username/pass - the 'trick' is to set Enabled to true in call to Get().

Unfortunately after pressing 'Login' button after some seconds Kazoo crashes?
Find all posts by this user
22-06-2015, 02:16 PM
Post: #4
RE: Credentials & Tidal
Kazoo will call Get() to read (a) whether a streaming service is enabled, and (b) whether it has a username and password set. If the service is not enabled, Kazoo will hide the tab for that service. Other behaviours for Tidal are documented at http://www.openhome.org/wiki/TidalStreamingService

If you want to force Kazoo to login again, go into the Tidal tab, press the person icon to the left of the search box then press Logout.

If you still get crashes from Kazoo, you might get a hint about their cause from C:\Users\[username]\AppData\Roaming\Kazoo\Kazoo.crash
Find all posts by this user
22-06-2015, 02:47 PM
Post: #5
RE: Credentials & Tidal
(22-06-2015 02:16 PM)simonc Wrote:  Kazoo will call Get() to read (a) whether a streaming service is enabled, and (b) whether it has a username and password set. If the service is not enabled, Kazoo will hide the tab for that service. Other behaviours for Tidal are documented at http://www.openhome.org/wiki/TidalStreamingService

If you want to force Kazoo to login again, go into the Tidal tab, press the person icon to the left of the search box then press Logout.

If you still get crashes from Kazoo, you might get a hint about their cause from C:\Users\[username]\AppData\Roaming\Kazoo\Kazoo.crash

Kazoo shows Tidal login dialog right away when started, that's ok - trick was to set Enabled parameter to true in Get() call.

However, after entering login info and pressing Login button it seems to be waiting for connection to Tidal and when that times out it crashes.

Kazoo.crash does not show anything interesting but UsersLog shows null pointer exception:

22/06/15 16:41:18: XappFormsTabHandler.Receive - unhandled exception:
Json:{"c":61,"d":[{"id":"227","type":"vclick","properties":[]}]}
Exception:System.NullReferenceException: Object reference not set to an instance of an object.
at Org.BouncyCastle.Security.DotNetUtilities.ToRSAParameters(RsaKeyParameters rsaKey)
at OpenHome.Os.ServiceCredentials.Encrypt(String aPublicKey, String aValue)
at OpenHome.Os.ServiceCredentialsNetwork.Set(String aId, String aUsername, String aPassword)
at OpenHome.Os.CredentialsSubscription.Set(String aUsername, String aPassword)
at Linn.KazooLib.Views.StreamingServiceView.<.ctor>b__0()
at Linn.KazooLib.Widgets.CredentialsPanelWidget.OnLogin()
at Linn.KazooLib.Widgets.CredentialsPanelWidget.<.ctor>b__a(Object s, EventArgs e)
at OpenHome.Org.JButton.OnVclick(IDictionary`2 aProperties)
at OpenHome.Os.App.ModuleControl.Receive(String aType, IDictionary`2 aProperties)
at OpenHome.Os.XappFormsTabHandler.Receive(String aJson)

Could it be it does not like empty password field it got from Get() call?

If so, then it's increasingly looking like Renderer simply must have login info i.e. cannot get it via CP?
Find all posts by this user
22-06-2015, 03:36 PM
Post: #6
RE: Credentials & Tidal
The renderer is expected to be provided with login info from the CP once and once only. After this, the renderer is expected to store its login info on disk.

The CP calls Get() on startup to decide whether the renderer already has login info. Non-empty return values for both username and password signify that the renderer does already have login info.

I'm certain that this can be made to work - we have two codebases that do exactly this Smile.

Based on the callstack you posted, I have a guess about the cause of the crash you're seeing - does your Credentials service return a valid RSA public key as its PublicKey state variable? This is required to allow Kazoo to encrypt the password before passing it via Set().
Find all posts by this user
22-06-2015, 04:05 PM (This post was last modified: 22-06-2015 05:04 PM by Josef.)
Post: #7
RE: Credentials & Tidal
GetPublicKey() is never called - Kazoo only calls Get(). Is there some special Status that needs to be passed too?

BTW - How do I know if PublicKey is valid? I used this link (http://travistidwell.com/jsencrypt/demo/) to generate a key and in CredentialProvider constructor set it like this:

SetPropertyPublicKey("MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAXpZI1Ilhodm3XPZtRDSfwX6UO14MqII5yI5sPUiYk4B1x/9fTvEEdL4tliZmNQ07mFAxLa/RMtFVC3r2dHqcgQIDAQAB");

GetPublickKey() just does:
GetPropertyPublicKey(aPublicKey);

But your guess might be on to something: I've just tried with Bubble on Android and it _does_ call GetPublicKey() but then also crashes - So at least we have some consistency here Smile

Hmmm - Is that public key OK?
Find all posts by this user
22-06-2015, 07:15 PM
Post: #8
RE: Credentials & Tidal
(22-06-2015 04:05 PM)Josef Wrote:  GetPublicKey() is never called - Kazoo only calls Get(). Is there some special Status that needs to be passed too?
There is a PublicKey state variable in Credentials. Kazoo reads this via a subscription.

(22-06-2015 04:05 PM)Josef Wrote:  BTW - How do I know if PublicKey is valid? I used this link (http://travistidwell.com/jsencrypt/demo/) to generate a key and in CredentialProvider constructor set it like this:

SetPropertyPublicKey("MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAXpZI1Ilhodm3XPZtRDSfwX6UO14MqII5yI5sPUiYk4B1x/9fTvEEdL4tliZmNQ07mFAxLa/RMtFVC3r2dHqcgQIDAQAB");

GetPublickKey() just does:
GetPropertyPublicKey(aPublicKey);

But your guess might be on to something: I've just tried with Bubble on Android and it _does_ call GetPublicKey() but then also crashes - So at least we have some consistency here Smile

Hmmm - Is that public key OK?

That doesn't look right. The Credentials service on Linn DS reports a much longer key in the form

-----BEGIN RSA PUBLIC KEY-----
380 chars in 64 char lines
-----END RSA PUBLIC KEY-----


The key is generated using openssl with code like
Code:
RAND_seed(aEntropy.Ptr(), aEntropy.Bytes());
BIGNUM *bn = BN_new();
ASSERT(BN_set_word(bn, RSA_F4));
RSA* rsa = RSA_new();
ASSERT(rsa != NULL);
ASSERT(RSA_generate_key_ex(rsa, aKeyBits, bn, NULL));
BN_free(bn);

BIO* bio = BIO_new(BIO_s_mem());
ASSERT(bio != NULL);
// skip code to persist key
ASSERT(1 == PEM_write_bio_RSAPublicKey(bio, rsa));
const int len = BIO_pending(aBio);
char* val = (char*)calloc(len+1, 1);
ASSERT(val != NULL);
BIO_read(aBio, val, len);
// set 'val' into Credentials PublicKey
Find all posts by this user
22-06-2015, 08:00 PM
Post: #9
RE: Credentials & Tidal
Hmmm - Are you saying that link is no good?
And openSSL is needed to generate proper key?

Ok, no problem, I tried running openSSL like this:

C:\OpenSSL-Win32\bin>openssl genrsa -out privkey.pem 2048
WARNING: can't open config file: /usr/local/ssl/openssl.cnf
Loading 'screen' into random state - done
Generating RSA private key, 2048 bit long modulus


C:\OpenSSL-Win32\bin>openssl rsa -in privkey.pem -pubout
WARNING: can't open config file: /usr/local/ssl/openssl.cnf
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzLy7SjHUkpnZtZ5mFJZ0
EXyiUpPaPOU4Q9tLa9odE7dqsOeEDY6nam/CKZRuSX1TL8wZx2+0BzcfYHiidXPi
oSsKI5j5QPwfDdcyw+FaRh4AybxrzLEnaKLJkeVnykkAxZU8b4LyypZijD+wl7Vf
1skB8mAfYJBJCb/3k33bBRiZ8XzIeUyLV3L9Znrv3bvS/Nerqf3TVXDmH+e0qADw
kI4HAsSv9wX4kThoTpWcYxrz4ox2LJD6jFN2hlp+8JA58cISvji8E+xs0D95dZUK
gSmvRrzrSiK6LkfNgjR1Rz0b+uww1P9AcjUfIFWs75qxAI/kr5f05IhgoNfwRmRC
nQIDAQAB
-----END PUBLIC KEY-----

So I copied this to:

SetPropertyPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzLy7SjHUkpnZtZ5mFJZ0EXyiUpPaPOU4Q9tL​a9odE7dqsOeEDY6nam / CKZRuSX1TL8wZx2 + 0BzcfYHiidXPioSsKI5j5QPwfDdcyw + FaRh4AybxrzLEnaKLJkeVnykkAxZU8b4LyypZijD + wl7Vf1skB8mAfYJBJCb / 3k33bBRiZ8XzIeUyLV3L9Znrv3bvS / Nerqf3TVXDmH + e0qADwkI4HAsSv9wX4kThoTpWcYxrz4ox2LJD6jFN2hlp + 8JA58cISvji8E+xs0D95dZUKgSmvRrzrSiK6LkfNgjR1Rz0b + uww1P9AcjUfIFWs75qxAI / kr5f05IhgoNfwRmRCnQIDAQAB");


No difference - Kazoo crashed with same error as before Sad

What's the catch? Smile
Find all posts by this user
22-06-2015, 09:11 PM
Post: #10
RE: Credentials & Tidal
(22-06-2015 08:00 PM)Josef Wrote:  Hmmm - Are you saying that link is no good?
And openSSL is needed to generate proper key?
Sorry, the link is broken so I'm not sure how you're generating a key.

You don't have to use openssl. I was just showing how we've generated keys.


(22-06-2015 08:00 PM)Josef Wrote:  Ok, no problem, I tried running openSSL like this:

C:\OpenSSL-Win32\bin>openssl genrsa -out privkey.pem 2048
WARNING: can't open config file: /usr/local/ssl/openssl.cnf
Loading 'screen' into random state - done
Generating RSA private key, 2048 bit long modulus


C:\OpenSSL-Win32\bin>openssl rsa -in privkey.pem -pubout
WARNING: can't open config file: /usr/local/ssl/openssl.cnf
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzLy7SjHUkpnZtZ5mFJZ0
EXyiUpPaPOU4Q9tLa9odE7dqsOeEDY6nam/CKZRuSX1TL8wZx2+0BzcfYHiidXPi
oSsKI5j5QPwfDdcyw+FaRh4AybxrzLEnaKLJkeVnykkAxZU8b4LyypZijD+wl7Vf
1skB8mAfYJBJCb/3k33bBRiZ8XzIeUyLV3L9Znrv3bvS/Nerqf3TVXDmH+e0qADw
kI4HAsSv9wX4kThoTpWcYxrz4ox2LJD6jFN2hlp+8JA58cISvji8E+xs0D95dZUK
gSmvRrzrSiK6LkfNgjR1Rz0b+uww1P9AcjUfIFWs75qxAI/kr5f05IhgoNfwRmRC
nQIDAQAB
-----END PUBLIC KEY-----

So I copied this to:

SetPropertyPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzLy7SjHUkpnZtZ5mFJZ0EXyiUpPaPOU4Q9tL​a9odE7dqsOeEDY6nam / CKZRuSX1TL8wZx2 + 0BzcfYHiidXPioSsKI5j5QPwfDdcyw + FaRh4AybxrzLEnaKLJkeVnykkAxZU8b4LyypZijD + wl7Vf1skB8mAfYJBJCb / 3k33bBRiZ8XzIeUyLV3L9Znrv3bvS / Nerqf3TVXDmH + e0qADwkI4HAsSv9wX4kThoTpWcYxrz4ox2LJD6jFN2hlp + 8JA58cISvji8E+xs0D95dZUKgSmvRrzrSiK6LkfNgjR1Rz0b + uww1P9AcjUfIFWs75qxAI / kr5f05IhgoNfwRmRCnQIDAQAB");


No difference - Kazoo crashed with same error as before Sad

What's the catch? Smile

The value you passed to SetPropertyPublicKey is different to the key you generated. You need to pass exactly that key - BEGIN/END lines and newlines inside the key and all.
Find all posts by this user


Forum Jump: