Configure SAP .NET Connector for SNC using config file in C#

Gareth picture Gareth · Apr 19, 2013 · Viewed 9.1k times · Source

We have a number of applications developed in C# that interface with SAP using the SAP .NET Connector 3.0. I'm very familiar with this, and have recently been asked to look at securing this interface by using the SNC (Secure Network Communications) options, which I've also been able to configure and get working.

However, I want to configure my SNC destinations entirely via config file and not programmatically. To specify an unsecure connection, I can specify the following destination in the config file:

<SAP.Middleware.Connector>
    <ClientSettings>
      <DestinationConfiguration>
        <destinations>          
          <add NAME="MySAPName" USER="MyUser" PASSWD="orly" CLIENT="100" LANG="EN" ASHOST="mysapname.mydomain.com" SYSNR="70" MAX_POOL_SIZE="20" IDLE_TIMEOUT="10"/>          
        </destinations>
      </DestinationConfiguration>
    </ClientSettings>
</SAP.Middleware.Connector>

But, to create a secure SNC connection, so far I've only figured out how to do it by configuring the destination programatically, e.g.:

  Params.Add(RfcConfigParameters.AppServerHost, "mysapname.mydomain.com");
  Params.Add(RfcConfigParameters.Name, "MySAPName"); 
  Params.Add(RfcConfigParameters.SystemNumber, "70");                                              
  Params.Add(RfcConfigParameters.Language, "EN");
  Params.Add(RfcConfigParameters.Client, "100");
  Params.Add(RfcConfigParameters.User,"MyUser");
  Params.Add(RfcConfigParameters.Password, "orly");                    

  // Additional Params for SNC, not settable in config?
  Params.Add(RfcConfigParameters.SncMode, "8");                    
  Params.Add(RfcConfigParameters.SncPartnerName, "p:CN=RemovedForConfidentiality, OU=, O=, L=,C=GB");                                                            
  Params.Add(RfcConfigParameters.SncMyName, "p:CN=MyRemovedPartnerName, C=GB, O=, OU=");
  Params.Add(RfcConfigParameters.SncQOP, "8");
  Params.Add(RfcConfigParameters.Trace, "2");

So, given this context my question is: Can I configure an SNC based SAP Destination using only the config file? If so, how?

I realise I could store SncPartnerName etc. in AppSettings but it would be much nicer if it were specifiable in the DestinationConfiguration section. I can't seem to find any documentation on this, however. I should note I'm aware of the the SAP SCN website and have had an unfruitful look on there, although I do not have access to the SAP Service Marketplace.

Answer

Gareth picture Gareth · Apr 22, 2013

A colleague of mine has managed to discover the solution. Sample config file with the parameters required for SNC is as follows:

<SAP.Middleware.Connector>
    <ClientSettings>
      <DestinationConfiguration>
        <destinations>          
          <add NAME="MySAPName" USER="MyUser" PASSWD="orly" CLIENT="100" LANG="EN"
                ASHOST="mysapname.mydomain.com" SYSNR="70" MAX_POOL_SIZE="20" IDLE_TIMEOUT="10"
                SNC_PARTNERNAME="p:CN=mycn.com, OU=A, O=B, L=C, C=GB" 
                SNC_MYNAME="p:CN=myname.com, C=GB, O=A, OU=B" 
                SNC_QOP="8" SNC_MODE="8" TRACE="2"/>          
        </destinations>
      </DestinationConfiguration>
    </ClientSettings>
</SAP.Middleware.Connector>