none
How to register secured peer name when opening a peer to peer channel ?

    Question

  • When a p2p channel is opened it registers an unsecured name with PNRP  "0.P2pTest". How can I make it to register a secured name instead ? like when creating a peer name:

    PeerName = new PeerName("P2PTest", PeerNameType.Secured);

    This is the code I am using to open a channel:

    _NetPeerTcpBinding = new NetPeerTcpBinding();          
    _NetPeerTcpBinding.Security.Mode = SecurityMode.TransportWithMessageCredential;                       
    EndpointAddress EndpointAddress = new System.ServiceModel.EndpointAddress("net.p2p://P2PTest");                   
    _Endpoint = new System.ServiceModel.Description.ServiceEndpoint(System.ServiceModel.Description.ContractDescription.GetContract(typeof(IChat)), _NetPeerTcpBinding, EndpointAddress);

    InstanceContext InstanceContext = new System.ServiceModel.InstanceContext(new Chat());           
    DuplexChannelFactory<IChatChannel> ChatChannelFactory = new DuplexChannelFactory<IChatChannel>( InstanceContext, _Endpoint);
    ChatChannelFactory.Credentials.Peer.MeshPassword = "123";
    ChatChannelFactory.Credentials.Peer.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, System.Security.Cryptography.X509Certificates.StoreName.Root, System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectName, "TEST COMPANY");

                _ChatChannel = ChatChannelFactory.CreateChannel();           
                IOnlineStatus ostat = _ChatChannel.GetProperty<IOnlineStatus>();
                ostat.Online += new EventHandler(OnOnline);
                ostat.Offline += new EventHandler(OnOffline);           
                try
                {
                    _ChatChannel.Open();
                   
                }
                catch (Exception ex)
                {
                    return ex;
                }
                return null;

    Friday, July 01, 2011 9:01 AM

All replies

  • Hi All!

    I am afraid I was not very clear on this. Let me try again:

    I haven't found any information on how to use registered peer name. This is weird, because all examples (and I wend through many) describe how to register peer name and resolve. Other examples where actual communication happens DO NOT register a name, they just open a channel and an unsecured name gets registered (how?). I do not get what is the connection between the two and respectively how to open a channel using a secured peer name or register the latter and use it when opening a channel. What am I missing ?

    I found other threads asking the same question:

    here and here 

    Is nobody trying to actually write something more with WCF P2P than a simple chat application with unsecured names which can not even go to the global cloud?

    Regards

    Raf

    Friday, July 08, 2011 3:57 PM