设为首页 收藏本站
查看: 1092|回复: 0

[经验分享] apache win openssl

[复制链接]

尚未签到

发表于 2015-7-31 12:29:18 | 显示全部楼层 |阅读模式
Rubayat Hasan
Software Development, Music, Web Design, life, thoughts…




  • Home
  • Portfolio
  • Projects
  • Contact
  • Categories

http://rubayathasan.com/wp-content/themes/modified-elegant-grunge/images/rss-t.png





APR22010Setting up Apache HTTPS/SSL on Windows


by Rubayat
posted in Tutorial
  I am assuming that you already have Apache2 installed and working on a Windows server.
  For SSL/HTTPS to work you need to download and setup the Win32 Binary including OpenSSL "httpd/apache_x.x.x-win32-x86-openssl-x.x.x.msi" on your Windows server.
  If you now have regular HTTP server working follow the guide below to setup HTTPS.
  
Setting up HTTPS on a Windows Server:


  • Creating a self-signed SSL Certificate using OpenSSL:
      Open the command prompt and cd to your Apache installations "bin" directory. Usually it would be:
      cd "C:\Program Files\Apache Software Foundation\Apache2.2\bin"
      To create the SSL certificate we will need the openssl.cnf files location but the default location set by OpenSSL for this file is setup according to a Linux distribution, so we need to fix it for Windows.
      We need to setup the Windows environment variable OPENSSL_CONF to point to the openssl.cnf files location. It is usually located in "C:\Program Files\Apache Software Foundation\Apache2.2\conf\openssl.cnf" directory.
      So we can set it up by the following command or through the GUI interface:
      set OPENSSL_CONF=C:\Program Files\Apache Software Foundation\Apache2.2\conf\openssl.cnf
      All files generated from the following commands will reside in "C:\Program Files\Apache Software Foundation\Apache2.2\bin" folder.
      Now that we have the environment variable set we need to create a new OpenSSL certificate request using the following command:
      
      openssl req -new -out server.csr
      It will ask you some questions and you can safely ignore them and just answer the following questions:
    PEM pass phrase: Password associated with the private key you’regenerating (anything of your choice).  
    Common Name: The fully-qualified domain name associated with this certificate (i.e. www.your-domain.com).
      Now we need to remove the passphrase from the private key. The file"server.key" created from the following command should be only readable by the apache server and the administrator. You should also delete the .rnd file because it contains the entropy information for creating the key and could be used for cryptographic attacks against your private key.
      openssl rsa -in privkey.pem -out server.key
      Now we need to set up an expiry date, it could be any time of your choice, we use 365 days below:
      openssl x509 -in server.csr -out server.cert -req -signkey server.key -days 365
      We have the Self-signed SSL certificates ready now. Now We need to MOVE the "server.cert" and "server.key" file to the
      "C:\Program Files\Apache Software Foundation\Apache2.2\conf" location.
  • Configuring Apache to run SSL/HTTPS server:
      Now that we have the Self-signed SSL certificate ready, all we need is to configure Apache to start the SSL server.
      First we modify the "C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf" file.
      Open up conf\httpd.conf in a text editor and look for the line:
      LoadModule ssl_module modules/mod_ssl.so and remove any pound sign (#) characters preceding it.
      Include conf/extra/httpd-ssl.conf and remove any pound sign (#) characters preceding it.
      Now we need to modify the "C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-ssl.conf". Let all the default options as it is but make sure to modify the following section according to your need:
      
        ServerAdmin some@email.com
        DocumentRoot "Your Root folder location"
        ServerName www.domain.com:443
        ServerAlias domain.com:443
        ErrorLog "logs/anyFile-error.log"
        CustomLog "logs/anyFile-access.log" common
        SSLEngine on
      SSLCertificateFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.cert"
      SSLCertificateKeyFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.key"

      Make sure that "SSLCertificateFile" and "SSLCertificateKeyFile" are properly located.
      For better organizing you can also put the whole  section in the "C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf" along with your other Virtual Host settings there but you need to uncomment “Include conf/extra/httpd-vhosts.conf” in your conf\httpd.conf file to use that.
  • Opening SSL/HTTPS port on Windows:
      Now we need to open an exception in Windows Firewall for TCP port 443. You can do that by going to “Windows Firewall” settings in Control Panel and adding a port in the exception section.
  Well that was long and painful but but now Restart the server and everything should work fine.
  Please feel free to leave comments if this guide helped.

Create Self-Signed CertificateC
  

  Related posts:


  • Guide to Running Apache on Windows or Ubuntu - After using IIS for almost 4 years now, I have...
  





























Leave a Comment
tags: Apache, HTTPS, OpenSSL, SSL, SSL Certificate
23 Responses to “Setting up Apache HTTPS/SSL on Windows”





Leave a Reply

   Name (required)
   Mail (will not be published) (required)
   Website
  

Click the "Preview" button to preview your comment here.  


This entry was posted on Friday, April 2nd, 2010 at 11:44 pmand is filed under Tutorial. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


  • Popular Posts

    • Enabling Line Break “” in Wordpress
    • Setting up Apache HTTPS/SSL on Windows
    • iPhone - Manually Backup SMS, Notes, Pictures, Video, MxTube Folder
    • Clearing NetBT in XP to Repair Network Connection
    • 98 Dodge Caravan Dash Light Blinking/Flashing

  • Topics

    Ad Integration Apachebackup bicycling cars CourseCricket csc321 dodge caravan driving Evelyn Glennie fav-vdos iisinfolinks iphone kernelLaptop Lecture MovieMusic NetBT Network Repair neural networks Newsnotes osx86 permalinkphotoblog picPostRogers safari park SA vs AUSservlet sms South Africa Cricket Star Trek stuntstomcat UofT winterWordpressWordpress PluginWordpress Theme XP zee avi





Subscribe RSS

Categories

  • Apps (2)
  • Blog (5)
  • Course (1)


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-92738-1-1.html 上篇帖子: 让apache只允许域名访问而禁止IP实现方法 下篇帖子: apache php 整合
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表