将表单从一个HTTPS发布到另一个HTTPS站点,从而导致安全警报

时间:2010-10-16 19:36:55

标签: asp.net post asp-classic webforms https

我需要将一个字符串从.NET站点发布到Classic ASP站点,这些站点托管在同一台服务器上(不同的虚拟目录)。

https://example.com/DOTNETSite/Sender.aspx

https://example.com/ClassicASP/SomeFolder/Target.asp

Target.asp页面有3种处理传入数据的方法:

  1. Form Post
  2. 查询字符串
  3. 接头
  4. 我无法在查询字符串中传递我的数据。所以选项已经结束。我正在尝试使用Form post方法,在服务器端构建一个表单并吐出javascript代码来执行form.submit()。但这导致Internet Explorer为用户抛出安全警报。我们想避免这种情况。请告诉我们克服这种情况的最佳方法是什么。非常感谢。

1 个答案:

答案 0 :(得分:0)

现在你正在做:

  

您的服务器---->您的客户/浏览器---->他们的服务器

相反,你应该使用:

  

您的服务器---->您的客户/浏览器---->你的服务器---->他们的服务器

即(如果不够清楚),让它将表单发送到您自己的服务器。 当您的服务器收到表单时,它应该将其发送到目标服务器。

在基础层面上,这是有效的。但是,如果用户应该在第二台服务器上登录等,则可能会出现问题。

我将尝试用PHP来说明一个例子:

文件: form.html

<form action="send.php" method="post">
    ....
</form>

文件: send.php

<?php
  $url='https://example.com/ClassicASP/SomeFolder/Target.asp';
  // create new cur connection
  $ch=curl_init();
  // tell curl target url
  curl_setopt($ch, CURLOPT_URL, $url);
  // tell curl we will be sending via POST
  curl_setopt($ch, CURLOPT_POST, true);
  // tell it not to validate ssl cert
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  // tell it where to get POST variables from
  curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); 
  // make the connection
  curl_exec($ch);
  // close connection
  curl_close($ch);
?>