天天看點

iOS7.1 企業級https釋出解決辦法

openssl使用的是macos系統自帶的版本,關鍵點是不能直接使用ios裝置打開https的連結,需要将證書發到系統的mail裡,安裝到裝置,

如果指令執行不成功,用sudo執行。

1.生成伺服器的私鑰

openssl genrsa -out server.key 1024

2.生成簽署申請(注意除Common Name以外可以為空,Common Name必須為伺服器的ip或域名)

openssl req -new -key server.key -out server.csr

3.生成CA私鑰

openssl genrsa  -out ca.key 1024 

4.利用CA的私鑰産生CA的自簽署證書

openssl req  -new -x509 -days 365 -key ca.key -out ca.crt

5.在目前目錄建立demoCA,裡面建立檔案index.txt和serial,serial内容為01,index.txt為空,以及檔案夾newcerts

openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key

将ca.crt檔案通過郵件發送到ios裝置的Mail上,進行證書的安裝

/private/etc/apache2/httpd.conf  ,編輯這個檔案去掉下面三行前面的 '#'

LoadModule ssl_module libexec/apache2/mod_ssl. so

Include  / private /etc/apache2/extra/httpd-ssl.confInclude/private/etc/apache2/extra/httpd-vhosts.conf

/private/etc/apache2/extra/httpd-ssl.conf ,編輯這個檔案去掉下面兩行前面的 '#'

SSLCertificateFile "/private/etc/apache2/ssl/server.crt"

SSLCertificateKeyFile  "/private/etc/apache2/ssl/server.key"

/private/etc/apache2/extra/httpd-vhosts.conf  ,編輯這個檔案在 'NameVirtualHost*:80' 後面添加:

NameVirtualHost *:443

在檔案末尾添加:

<VirtualHost *:443>
    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile /private/etc/apache2/ssl/server.crt
    SSLCertificateKeyFile /private/etc/apache2/ssl/server.key
    ServerName localhost
    DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>
           

到這裡就配置完了,檢查配置,沒問題的話重新開機Apache就好了

sudo apachectl configtest

sudo apachectl restart

iOS