vb.net - WCF webservice with custom certificate validation -


i hosting wcf webservice custom certificate validation, not able configure properly. when try wsdl of webservice, compilation error below. doing wrong?

thanks

edit:

i've looked into: custom certificate validation in wcf service , authentication of clientcertificate element , how to: create service employs custom certificate validator , x.509 certificate validator , none of links describe issue having.

compilation error message:

could not load file or assembly 'service' or 1 of dependencies. system cannot find file specified. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.  exception details: system.io.filenotfoundexception: not load file or assembly 'service' or 1 of dependencies. system cannot find file specified. source error:  unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. 

web.config:

  <system.servicemodel>     <bindings>       <basichttpbinding>         <binding name="transportsecurity">           <security mode="message">             <message clientcredentialtype="certificate" />           </security>         </binding>       </basichttpbinding>     </bindings>     <behaviors>       <servicebehaviors>         <behavior name="myservicebehavior">           <servicemetadata httpsgetenabled="true" httpsgeturl="" />           <servicedebug includeexceptiondetailinfaults ="true"/>           <servicecredentials>             <clientcertificate>               <authentication certificatevalidationmode="custom" customcertificatevalidatortype = "myproject.myx509certificatevalidator, service"/>             </clientcertificate>             <servicecertificate findvalue="hashvalue" storelocation="localmachine" storename="my" x509findtype="findbythumbprint" />           </servicecredentials>         </behavior>       </servicebehaviors>       <endpointbehaviors>         <behavior name="clientbehavior">           <clientcredentials>             <servicecertificate>               <authentication certificatevalidationmode="custom"  customcertificatevalidatortype="myproject.myx509certificatevalidator, client"/>             </servicecertificate>           </clientcredentials>         </behavior>       </endpointbehaviors>     </behaviors>     <services>       <service name="myproject.myprojectwcf" behaviorconfiguration="myservicebehavior">         <endpoint address="" binding="basichttpbinding" bindingconfiguration="transportsecurity" contract="myproject.imyprojectwcf" />         <endpoint address="mex" binding="mexhttpsbinding" contract="imetadataexchange" />       </service>     </services>   </system.servicemodel> 

wcf code:

imports system.servicemodel imports system.servicemodel.description imports system.identitymodel.selectors imports system.security.cryptography.x509certificates imports system.identitymodel.tokens imports system.servicemodel.security  namespace myproject     ' note: can use "rename" command on context menu change class name "myprojectwcf" in code, svc , config file together.     <servicebehavior()> _     public class myprojectwcf         implements imyprojectwcf          public function helloworld() string implements imyprojectwcf.helloworld             return "namespace: [" + me.gettype().namespace + "]" + vbnewline + "normal response"         end function          sub new()             dim servicehost new servicehost(gettype(myprojectwcf))             try                 servicehost.credentials.clientcertificate.authentication.certificatevalidationmode = x509certificatevalidationmode.custom                 servicehost.credentials.clientcertificate.authentication.customcertificatevalidator = new myx509certificatevalidator("cn=mycertificate")                 servicehost.open()                 'servicehost.close()                             'servicehost.close()             end try         end sub     end class      public class myx509certificatevalidator         inherits x509certificatevalidator         private allowedissuername string          public sub new(byval allowedissuername string)             if allowedissuername nothing                 throw new argumentnullexception("allowedissuername")             end if             me.allowedissuername = allowedissuername         end sub          public overrides sub validate(byval certificate x509certificate2)             ' check there certificate.             if certificate nothing                 throw new argumentnullexception("certificate")             end if             ' check certificate issuer matches configured issuer.             if allowedissuername <> certificate.issuername.name                 throw new securitytokenvalidationexception _                   ("certificate not issued trusted issuer")             end if         end sub     end class end namespace 

interface code:

imports system.servicemodel imports system.security.permissions  namespace myproject     ' note: can use "rename" command on context menu change interface name "imyprojectwcf" in both code , config file together.     <servicecontract([namespace]:="myproject")> _     public interface imyprojectwcf         <operationcontract()> _         function helloworld() string     end interface end namespace 

edit 2 (with fix):

insert default constructor cert validator class:

    public sub new()         me.new("cn=yourcertificate here")     end sub 

and had figure out project name of website is, app_code, gets compiled bunch of other pages 1 dll, app_code.dll. final line in web.config looks this:

<authentication certificatevalidationmode="custom" customcertificatevalidatortype="myproject.myx509certificatevalidator, app_code"/> 

so there no compiled errors , wsdl. thank :)

i think have change

customcertificatevalidatortype = "myproject.myx509certificatevalidator, service"/>

to

customcertificatevalidatortype = "myproject.myx509certificatevalidator, myproject"/>

because 'service' it's not in namespace. maybe pasting msdn, have think msdn wcf demo projects ('101 samples'), used called 'service'.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -