Coldfusion: CFHTTP with SSL encrypted Page (https://) - got an error

孤街浪徒 提交于 2020-01-15 07:07:27

问题


I'm making an cfhttp to connect to an encrypted page. Seems to work fine for some sites.

I/O Exception: Name in certificate `pro.test.com' does not match host name `go.test.com'

Is there a workaround to trust this certificate even if the host name doesn't match?


回答1:


Think this is more Java question, and workaround should be affecting the JRE.

Not sure if this will work in your case, but possible solution is to import this certificate into the JRE keystore.

Generic description can be found at Sun website. Though process is pretty simple.

First you should navigate the needed HTTPS URL with your browser and export the cert using SSL properties (don't remember how it is done in IE, but in Firefox something like Security > View cert > Details > Save as -- still not sure because using non-English licalization), any X.509 type should work.

Next you should import it using keytool. Navigate to the current CF JRE's bin, execute the following command (replace arguments with your values) and restart CF:

keytool -keystore <path to keystore> -import -file <path to certificate> -alias <alias>

BTW, there is a UI tool for this, but I haven't used it so can't say if it works fine.




回答2:


The sites that are probably working have a valid SSL Certificate from a trusted authority.

If you have control of pro.test.com, the preferred answer would be to get a valid cert for pro.test.com installed. But if that is not possible for some reason, I see two other options:

1) Do a try/catch where you try to connect via https, and fall back on http in the event of an SSL error. Obviously this would eliminate encryption for the failed connection.

or

2) Use Sergii's solution to import the key for that site into the Java keystore.




回答3:


If go.test.com is just a development server, in that case you can create a self-signed certificate and import it into Java keystore. That way you can save up on cost by not paying to CA and get a quicker turnaround to resolve the issue



来源:https://stackoverflow.com/questions/1938913/coldfusion-cfhttp-with-ssl-encrypted-page-https-got-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!