简体   繁体   中英

C# / WPF / SQL - How to encrypt connectionstring in web.config of WCF which will be deployed to remote Cloud

The architect of my software is,
WPF(Windows desktop application)- WCF middleware(on remote Cloud)- Cloud SQL Server(SQL database)

If I encrypt connnectionstring(to Cloud SQL database) in web.config through DPAPI on my development machine(computer), it seems the key of DPAPI will be not valid when WCF will be deployed to remote Cloud. Therefore, I think I need to encrypt with a way of RSA to export the key to remote Cloud where the WCF will be deployed.

As my major is not software-related but just bio-chemistry, I'm much worried whether my idea is right or not..

Could somebody help me whether my idea is right or not and if right, please let me know how to export the Key(would be highly appreciated if as detail as possible..)

For your understanding, I encrypted through both RSA and DPAPI but failed with like (when I didn't export the key) exceeds maximum key 128 byte and key is not valid respectively.

Thank you so much !

I've finally succeeded in encrypting connectionstring and connecting to Azure SQL database after almost 1 month of struggling. Rather than DPAPI, RSA ProtectedConfigurationProvider, we can encrypt through PKCS12ProtectedConfigurationProvider and connect to Azure. There's also some Microsoft's expired older blog but this link of TechNet(Microsoft) is still available. http://social.technet.microsoft.com/wiki/contents/articles/2951.windows-azure-sql-database-connection-security.aspx#_Download_and_Compile

And we need to install the PKCS12 provider correctly through NUGET and need to install the certificate on the New Azure Portal in the course of making new cloud service.

I hope my difficult experience helps someone who has to solve some problem like mine.

Thank you !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM