简体   繁体   中英

Storing public key in web.config file

I am trying to store a public key in the web.config file of an ASP.NET website as follows:

<add key="public_key" value="<RSAKeyValue><Modulus>zDYX4tbHSyTrwDmjSXiiFTo0ydGK50zxtH2lGL90oWrshMGy16wod7AZMfm8CMd/Rxl3ocIPLTmHSwyBb0xzL6lnF8uJI90s2TBHYemx3tkRQCcW6PZfGBWwlwSzhaNidbibRtoWNImBG4ehzc5Yxg3r6IyUBEtY9xJkL1tIezU=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"/>

This code is located inside the appSettings section of the web.config file. Unfortunately, it is giving me the following warning along with a number of other errors:

Warning 6   The element 'appSettings' has invalid child element 'RSAKeyValue'. List of possible elements expected: 'add, remove, clear'.

How can I solve this problem please? Thank you :)

You need to escape special characters ( < with &lt; and > with &gt; ) in this case, because in current state they turn web.config into invalid XML.

Here is the escaped string obtained here :

&lt;RSAKeyValue&gt;&lt;Modulus&gt;zDYX4tbHSyTrwDmjSXiiFTo0ydGK50zxtH2lGL90oWrshMGy16wod7AZMfm8CMd/Rxl3ocIPLTmHSwyBb0xzL6lnF8uJI90s2TBHYemx3tkRQCcW6PZfGBWwlwSzhaNidbibRtoWNImBG4ehzc5Yxg3r6IyUBEtY9xJkL1tIezU=&lt;/Modulus&gt;&lt;Exponent&gt;AQAB&lt;/Exponent&gt;&lt;/RSAKeyValue&gt;

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