11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 12 ■ DEVELOPING PEER-TO-PEER APPLICATIONS WITH WCF 391ramrameshreddy.blog.comagain here. As you can see in the listing, the password for both the host and the ChannelFactory isset via the Credentials.Peer.MeshPassword property. The binding configuration has beenupdated and is read from QuickTraderChatSecurePasswordEndPoint.Listing 12-12. Service Host Implementationprivate void StartService(){//Instantiate new ServiceHosthost = new ServiceHost(this);}//Set the passwordhost.Credentials.Peer.MeshPassword = password;//Open ServiceHosthost.Open();//Create a ChannelFactory and load the configuration settingchannelFactory = new ChannelFactory("QuickTraderChatSecurePasswordEndPoint");//Set the password for the ChannelFactorychannelFactory.Credentials.Peer.MeshPassword = password;//Create the Channelchannel = channelFactory.CreateChannel();//Lets others know that someone new has joinedchannel.Say("Admin", "*** New User " + userID +" Joined ****" + Environment.NewLine);One interesting behavior with the security is that if you have a set of peers listening on thesame endpoint but with different passwords, then they will be isolated from each other. Forexample, say you have four users called User1, User2, User3, and User4. Say User1 and User2are chatting and connected to the mesh using “password1.” If User3 and User4 start chattingwith another password, say “password2,” then even though all four users are on the mesh andlistening on the same endpoint, the messages between User1 and User2 cannot be seen byUsers3 and User4, and vice versa.ramrameshreddyramrameshreddy■Tip To use an X.509 certificate instead of a password to secure a mesh, set the transport credentialTypein the binding to Certificate, and set the Credentials.Peer.Certificate property to the certificate onboth the host and the client.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!