title: OPC UA Client - BadCertificateHostNameInvalid - opcfoundation.org
body: <p>We've got an older VB .NET (Visual Studio 2013 Community Edition) piece of code that currently communicates with a PLC over UDP for some <em>very</em> rudimentary data transfer.</p>
  
  <p>We are needing tighter coupling between the PLC and the PC now (the PC must be able to set a bunch of parameters, and a Labview program may want to access the PLC directly), so our PLC vendor (B&amp;R) said OPC UA was the way to go.</p>
  
  <p>This seems similar to the question posed here:</p>
  
  <p><a href="https://stackoverflow.com/questions/42718592/opc-ua-client-sdk-for-c-net-application-development">OPC-UA client SDK for C#.NET application development</a></p>
  
  <p>In an introductory seminar to OPC UA, we got compiled versions of the OPC UA client, and if I fire up a PLC simulator, the client can connect to the PLC simulator.  Of course, it asks for a name and a password, but a pop-up does show up that says  I try to connect, I get a pop-up window for the UA Sample Client that says "Certificate could not be validated: BadCertificateUntrusted"</p>
  
  <p>OK, I don't have a certificate.  You click through, and the client continues onwards, and shows a tree of all the elements that have been exposed to OPC UA by the PLC code.  All is well.</p>
  
  <p>Now, if I download the full code from the opcfoundation.org site, I can compile the code, <em>but</em>, when going through this same test sequence, after acknowledging that I don't have a valid certificate, another window pops up that says:</p>
  
  <p>EXCEPTION (ServiceResultException)
  BadCertificateHostNameInvalid
  SERVICE RESULT (BadCertificateHostNameInvalid)</p>
  
  <p>These are both OPC UA 1.02, BTW.</p>
  
  <p>Does something have to be configured elsewhere?  I noticed there are a few XML files (Opc.Ua.SampleClient.Config.xml, and Opc.Ua.SampleClient.Endpoints.xml), and I'm wondering if they have to modified to get rid of this stoppage.</p>
  
  <p>I do recall reading that that something won't be OPC UA compliant if you automatically allow this to be OK (of course), so you can't just make this automagically happen, but that's OK with me.</p>
  
  <p>The drawbacks to using the OPC UA code is that it is a bit deep (as noted by user Brino in the original StackOverflow post), and that it requires your own code to be released under GPL, so Unified-Automation looks pretty enticing, since we may not want to release our source code.</p>
  
  <p>Any thoughts on this particular problem?</p>