Skip to content

Instantly share code, notes, and snippets.

static void Main(string[] args)
{
using (ServiceHost host = new ServiceHost(typeof(Service)))
{
host.Description.Behaviors.Add(new ServiceMetadataBehavior() {
HttpGetEnabled = true,
HttpGetUrl = new System.Uri("http://localhost:7171/")});
var ep = host.AddServiceEndpoint("IService", new BasicHttpBinding(),
"http://localhost:7171/");
ep.Behaviors.Add(new MyWsdlExporter());
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#_0">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>b5GCZ2xpP5T7tbLWBTkOl4CYupQ=</DigestValue>
var SignedXml = require('xml-crypto').SignedXml
, FileKeyInfo = require('xml-crypto').FileKeyInfo
, fs = require('fs')
var xml = "<library>" +
"<book>" +
"<name>Harry Potter</name>" +
"</book>"
"</library>"
<library>
<book Id="_0">
<name>Harry Potter</name>
</book>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#_0">
<Transforms>
var select = require('xml-crypto').xpath.SelectNodes
, dom = require('xmldom').DOMParser
, SignedXml = require('xml-crypto').SignedXml
, FileKeyInfo = require('xml-crypto').FileKeyInfo
, fs = require('fs')
var xml = fs.readFileSync("signed.xml").toString()
var doc = new dom().parseFromString(xml)
var signature = select(doc, "/*/*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']")[0]
var sig = new SignedXml()
<customBinding>
<binding name="NewBinding0">
<textMessageEncoding />
<security authenticationMode="MutualCertificate"
messageSecurityVersion="WSSecurity10...">
<secureConversationBootstrap />
</security>
<httpTransport />
</binding>
</customBinding>
<wsHttpBinding>
<binding name="NewBinding1">
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
[ServiceBehavior(ProtectionLevel=ProtectionLevel.SignOnly)]
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" ... >
<Header>
<ws:Action>http://tempuri.org/IService/GetData</ws:Action>
<ws:To>http://localhost:8888/</ws:To>
<ws:MessageID>ca62b7d7-4f74-75ed-9f5c-b09b173f6747</ws:MessageID>
<ws:ReplyTo>
<ws:Address>...</ws:Address>
</ws:ReplyTo>
<o:Security>
<u:Timestamp xmlns:wsu="..." wsu:Id="_1">
var wcf = require('wcf.js')
, fs = require("fs")
, TextMessageEncodingBindingElement = wcf.TextMessageEncodingBindingElement
, HttpTransportBindingElement = wcf.HttpTransportBindingElement
, SecurityBindingElement = wcf.SecurityBindingElement
, CustomBinding = wcf.CustomBinding
, Proxy = wcf.Proxy
var binding = new CustomBinding(
[ new SecurityBindingElement({AuthenticationMode: "MutualCertificate"})