Site.Config Encrypted Example

This example depends on a Smartsite.Test.config file in the site root directory (not the web root), containing the following xml:

XML CopyCode image Copy Code
<?xml version="1.0" encoding="utf-8"?>
<configuration xsi:schemaLocation="http://schemas.microsoft.com/.NetConfiguration/v2.0 System/Schemas/Configuration/smartsite.data.config.xsd" 
    xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <smartsite.test>
  <singlenode id="single1" test="a">b</singlenode>
  <singlenode id="single2" test="aaa">bbb</singlenode>
  <nested id="nestplain">
   <singlenode id="single3" test="abcd">abcdef</singlenode>
  </nested>
  <encrypted>
   <singlenode id="encrypted1" test="enc1">asdf</singlenode>
   <nested id="nestenc">
    <singlenode id="singleenc" test="xyz">12345</singlenode>
   </nested>
  </encrypted>
 </smartsite.test>
</configuration>

The "encrypted" node is to be encrypted using the configprotect tool in the site's Bin folder:

  CopyCode image Copy Code
ConfigProtect.exe /encrypt /xpath:"//sc:encrypted" Smartsite.Test.config

Note that the GetValue viper doesn't resolve when trying to select an encrypted part of the config file.

Smartsite SXML CopyCode image Copy Code
{site.config.getvalue("../smartsite.test.config","c:configuration/c:smartsite.test/c:encrypted/c:nested/c:singlenode",default='NA')}
{site.config.getencryptedvalue("../smartsite.test.config","c:configuration/c:smartsite.test/c:encrypted/c:nested/c:singlenode",default='NA')}
{site.config.getencryptedsection("../smartsite.test.config","c:configuration/c:smartsite.test/c:encrypted/c:nested",default='NA')}
Example Result CopyCode image Copy Code
NA
12345
<nested id="nestenc" xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><singlenode id="singleenc" test="xyz">12345</singlenode></nested>