Search code examples
c#.net-remotingsecurestring

Using System.Security.SecureString in .NET Remoting App?


I am developing a Remoting application where a client looks up store specific information to login to a web server. It sets the user name and passwords in a class that stores the properties as System.Security.SecureString. I then try to pass the class with the login credentials to a server object that uses it to connect to the web host, get and some information back. When I call the server method I this error:

Type 'System.Security.SecureString' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
The class that contains the SecureStrings is marked as serializeable, and this was working while developing until I added the SecureString properties. Is there something I need to do to make this work, or am I going to have to change SecureString to String?


Solution

  • It is very difficult to get data from a SecureString, which is a good thing. If you want to use SecureString you'll have to implement a custom Serializer on your object that can take the SecureString and save it as something usable (maybe even encrypting it in the process).