apex code - Salesforce webservice call -
i trying following;
from salesforce.com call http or post , post json object using httprequest system class. getting following exception (it https):
java.security.cert.certificateexception: no name matching issue mywebsite.com found i have configured website in remote host already. have idea wrong here?
are missing call req.setclientcertificatename?
i have apex code salesforce calls out web service on site. protected client-side ssl. website, host, authorizes client cert salesforce.com (vs traditional web ssl browser client authorizes server cert). can create self-signed certificate in salesforce admin under certificate , key management , reference call req.setclientcertificatename. here code production org:
httprequest req = new httprequest(); req.setmethod('post'); req.setheader('host', 'www.mywebsite.com'); req.setendpoint('https://www.mywebsite.com/post.asp'); try { req.setclientcertificatename('cert_for_mywebsite'); } catch (system.calloutexception e) { // cert doesn't make sandbox } req.setheader('connection', 'keep-alive'); req.setheader('content-type', 'text/plain'); req.setheader('content-length', body.length().format()); req.setbody(body); http http = new http(); httpresponse res = http.send(req); system.debug(res.tostring()); system.debug('status:' + res.getstatus()); system.debug('status_code:' + res.getstatuscode()); on server (iis 7.5) enabled self-signed cert web.config:
<configuration> <system.webserver> <security> <access sslflags="ssl, sslnegotiatecert, sslrequirecert" /> <authentication> <iisclientcertificatemappingauthentication enabled="true" onetoonecertificatemappingsenabled="true"> <onetoonemappings> <!-- production salesforce --> <add enabled="true" username="salesforce" password="[enc:aesprovider:aaa...aaa:enc]" certificate="miieaaa...aaa=" /> </onetoonemappings> </iisclientcertificatemappingauthentication> </authentication> </security> </system.webserver> </configuration>
Comments
Post a Comment