dongshang5862 2011-10-19 05:29 采纳率: 0%
浏览 93
已采纳

如何为开发环境模拟https环境/ SSL证书?

I have a PHP application which runs on production like this :

<?php

    /*
    Do some work here
    */

    /* if https environment, redirect to secure next url */
    if(empty(isset["HTTPS"]) == true )  /* FIRST DEPENDECY */
    {
      header("location : https://mynext_prod_url?parameters"); /*SECOND DEPENDENCY */
    }
    else
    {
       header("location : http://mynext_prod_url?parameters");
    }
?>

This works absolutely fine in production where a SSL certificate is installed. To simulate the same scenarios in development, I can overcome first dependency, but how shall I overcome the second ?

/* Development example with workarounds */

  <?php

        /*
        Do some work here
        */
        $_SERVER['HTTPS'] = "TRUE" ;         /* fake HTTPS  */   

        if(isset($_SERVER["HTTPS"]) == true )  /* FIRST DEPENDECY SOLVED */
        {
          /* BUT THIS URL DOES NOT WORK AS IT ONLY EXISTS ON HTTP */
          header("location : https://mynext_dev_url?parameters"); 
        }
        else
        {
           header("location : http://mynext_dev_url?parameters");
        }
    ?>

How can I install a temporary certificate for development purpose ? Or somehow fake the environment .

  • 写回答

1条回答 默认 最新

  • dsdt66064367 2011-10-19 05:47
    关注

    You can create your own certificates that you can use in development. The mechanism to create certificates varies, by the platform. Here is an article about how to create one using XAMPP on Windows:

    http://jaswanttak.wordpress.com/2010/04/15/configure-ssl-on-xampp-and-windows/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退