This project has moved. For the latest updates, please go here.

"Key not valid for use in the specified state" error

Mar 24, 2011 at 4:07 PM

When I try to run the publisher / subscriber examples on an XP machine I get an error around the lines -

string test = "This is a test...";
test = test.Encrypt("MyPassword", CipherStrength.Aes256);

The exception is being thrown by the TVA.Security.Crytography.Cipher assemblies "Key not valid for use in the specified state".
It seems to happen on all the development machines we have at our company - so it could be related to a security policy.

Googling it turns up lots of examples, but it seems they all relate to a specific product (SQL, third party libraries...) but none of the fixes seem to work for me.
I even tried recreating my user profile but that does not help either.

Anyone have any ideas?

Thanks,

Steve

Coordinator
Mar 24, 2011 at 4:41 PM
Edited Mar 24, 2011 at 4:43 PM

Just checked in a change to the code library that may help with this error:

http://tvacodelibrary.codeplex.com/SourceControl/list/changesets

We'll roll these new changes into updated depenencies for the time-series library soon (next week) - in the mean-time you can grab new code library assemblies and overwrite your current dependencies (just uncheck read-only flags on files and overwrite)...

Ritchie

Coordinator
Mar 24, 2011 at 4:45 PM

Also, you might try deleting your KeyIVCache.bin and let the app create another.

Mar 24, 2011 at 7:37 PM

Thanks for the reply - after I deleted the keycache the openPDC application reports it cannot start a required Windows Service and then quits.

It did not recreate the keycache file.

 

Steve

Coordinator
Mar 24, 2011 at 9:24 PM

I am a little confused, I though you were running sample code.

Related to your openPDC error, can you provide the ErrorLog.txt?

Thanks!

Mar 24, 2011 at 10:03 PM

When you mentioned the KeyIVCache.bin file, I did a windows search for it.
The only result was in the openPDC application folder so I tried to delete that.

I re-ran the openPDC installer to put it back, and then copied it to the folder the test application was being built to. That seemed to fix the "key" error.

Now I have a problem in that the DataPublisher is trying to open a port 0.0.0.0:6165 as the 'interface' property has not been set in the m_configData object :

m_tcpServer = Transport.CreateSocket(m_configData[

"interface"], int.Parse(m_configData["port" ]), ProtocolType.Tcp);

When I look at the configuration string it only specifies "Port=6165" - could my upgrade of the TVA library have anything to do with this?

Thanks,

Steve

Coordinator
Mar 24, 2011 at 11:55 PM

Try adding interface=0.0.0.0 to your connection string for IPv4, or interface=::0 for IPv6

Mar 25, 2011 at 2:13 PM

Do you mean 127.0.0.1 or localhost?

By default it's set to 0:0:0:0 and that's what seems to be giving the error.

I tried setting the connection string property like this:

publisher.ConnectionString = "interface=127.0.0.1;port=6165";

 // Initialize publisher
publisher.Initialize();

// Start publisher
publisher.Start();

But when I step into Initialize() I arrive at the TcpServer ValidateConfigurationString() it seems to be being called with just "port=6165".

Should setting the ConnectionString property affect this? 

Steve 

Mar 25, 2011 at 2:30 PM
Edited Mar 25, 2011 at 2:31 PM

Quick update : I'm starting to think that the machine policies and possibly the McAfee suite might have something to do with this.

I ran it on another machine last night and it works fine "as is".

This may be something I'll have to take up with the IT department.

Coordinator
Mar 25, 2011 at 3:27 PM
Edited Mar 25, 2011 at 3:29 PM

No problem. Do note, however, the interface key is used to allow socket access over a specfic network card (specified by the NIC IP address), so I'm suprised the loopback address works. In the case of interface=0.0.0.0, this means use the default NIC using IPv4.