public static void EncryptContractNote(STPProvider.PostTradeServiceWse postTradeSvc) { //Open the current user certificate store and look for Personal category X509CertificateStore localStore = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore); localStore.OpenRead(); //Find STP-Provider A Certificate X509CertificateCollection certCollection = localStore.FindCertificateBySubjectString("STP-Provider A"); X509Certificate provCert = certCollection[0]; //Create a new security token that is of X509 type //Token represent claim (authentication information) X509SecurityToken token = new X509SecurityToken(provCert); postTradeSvc.RequestSoapContext.Security.Tokens.Add(token); //Instruct WSE inbound filter to encrypt the message before it is transmitted over wire postTradeSvc.RequestSoapContext.Security.Elements.Add(new EncryptedData(token)); }
public void EncryptAckResponse() { //Open the current user certificate store and look for Personal category X509CertificateStore localStore = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore); localStore.OpenRead(); //Find Vendor A Certificate X509CertificateCollection certCollection = localStore.FindCertificateBySubjectString("Vendor B"); X509Certificate provCert = certCollection[0]; //Create a new security token that is of X509 type //Token represent claim (authentication information) X509SecurityToken token = new X509SecurityToken(provCert); ResponseSoapContext.Current.Security.Tokens.Add(token); //Instruct WSE inbound filter to encrypt the message before it is transmitted over wire ResponseSoapContext.Current.Security.Elements.Add(new EncryptedData(token)); }