Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech QA/Testing 2 years ago
Posted on 16 Aug 2022, this text provides information on QA/Testing related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I have a WCF service which uses basicHttpBinding. Now I want to secure my methods">methods so that no one can create a proxy and use my method. I used WCF client certification from msdn. But cant move further. here is my web.config
address="http://localhost:57246/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="DataServiceBehavior"> baseAddress="http://localhost:57246/Service1.svc"/> address="" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="ServiceReference1.IService1" /> address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> name="BasicHttpBinding_IService1"> mode="Message"> realm="" /> clientCredentialType="Certificate" /> name="DataServiceBehavior"> httpGetEnabled="True"/> includeExceptionDetailInFaults="False" /> findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" /> certificateValidationMode="PeerOrChainTrust" />
now what should pass call form the c sharp. I have a method in WCF named showGrid.
public DataSet showGrid() { SqlDataAdapter da = new SqlDataAdapter("Select * FROM Resources", con); DataSet ds = new DataSet(); da.Fill(ds); return ds; }
and trying to call it like this on a button click
protected void btnShow_Click(object sender, EventArgs e) { var client = new ServiceReference1.Service1Client(); client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "localhost"); client.showGrid(); GridView1.DataSource = client.showGrid(); REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
Just add client certificate like this
client.ClientCredentials.ClientCertificate.Certificate = yourcert;
Edit:
X509Certificate2 yourcert= null; var store = new X509Store(storeName, storeLocation); store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly); var certCollection = store.Certificates.Find(findType, thumbprint, false); if (certCollection.Count>0) yourcert= certCollection[0]; store.Close();
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.