mac中apache开启https功能,本地发布安装app

mac中apache开启https功能,本地发布安装app

最近app进入收尾阶段,发包比较频繁。很多手机都不在测试证书中,所以使用的是企业证书打包。

每次上传到外网服务器都很慢,需要15分钟左右。想想还是自己本地mac做个服务器下载比较快一点。

所以学了下apache开启https的内容,本文记录了自己的学习过程。

1-先制作自己的签名证书

在前面的apache相关中,已经在mac上开启了apache,为了后面手机安装证书方便,我是在
/Library/WebServer/Documents/目录中制作签名证书的。

a-生成私钥,命令:
sudo openssl genrsa -des3 -out app.key 1024

b-生成签署申请,命令:
sudo openssl req -new -key app.key -out app.csr

c-生成服务器的私钥,命令:
sudo openssl rsa -in app.key -out server.key

d-生成给网站服务器签署的证书,命令:
sudo openssl req -new -x509 -days 3650 -key server.key -out server.crt

(这一步和a差不多,需要注意的是Common Name一定要填对)

以下是我自己在mac 10.10上处理的命令记录:

zhuruhongdeMacBook-Pro:~ zhuruhong$ cd /Library/WebServer/Documents/

zhuruhongdeMacBook-Pro:Documents zhuruhong$ ls

PoweredByMacOSX.gif index.html.en php

PoweredByMacOSXLarge.gif ios

zhuruhongdeMacBook-Pro:Documents zhuruhong$ cd ios/

zhuruhongdeMacBook-Pro:ios zhuruhong$ ls

KDaijiaDriver_1.0.0_9291.ipa app.csr ipa.html server.key

KDaijiaDriver_enter.plist app.key server.crt

zhuruhongdeMacBook-Pro:ios zhuruhong$

zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo openssl genrsa -des3 -out app.key 1024

Generating RSA private key, 1024 bit long modulus

.....++++++

.........++++++

e is 65537 (0x10001)

Enter pass phrase for app.key:[这里是输入密码]

Verifying - Enter pass phrase for app.key:[这里再次输入密码确认]

zhuruhongdeMacBook-Pro:ios zhuruhong$

zhuruhongdeMacBook-Pro:ios zhuruhong$
sudo openssl req -new -key app.key -out app.csr

Enter pass phrase for app.key:

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter ‘.‘, the field will be left blank.

-----

Country Name (2 letter code) [AU]:CN[这里是国家,CN中国]

State or Province Name (full name) [Some-State]:hangzhou[这里是省份,城市]

Locality Name (eg, city) []:hangzhou[这里是城市]

Organization Name (eg, company) [Internet Widgits Pty Ltd]:hz ltd[这里是公司]

Organizational Unit Name (eg, section) []:rh[这里是组织名称]

Common Name (e.g. server FQDN or YOUR name) []:192.168.2.1[这个必须填正确,是你的服务器的域名,或者ip]

Email Address []:[email protected][这里是我的邮箱]

Please enter the following ‘extra‘ attributes

to be sent with your certificate request

A challenge password []:123456[这里是密码]

An optional company name []:rh[这里是名字]

zhuruhongdeMacBook-Pro:ios zhuruhong$

zhuruhongdeMacBook-Pro:ios zhuruhong$
sudo openssl rsa -in app.key -out server.key

Enter pass phrase for app.key:[这里输入密码]

writing RSA key

zhuruhongdeMacBook-Pro:ios zhuruhong$

zhuruhongdeMacBook-Pro:ios zhuruhong$ 
sudo openssl req -new -x509 -days 3650 -key server.key -out server.crt

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter ‘.‘, the field will be left blank.

-----

Country Name (2 letter code) [AU]:CN

State or Province Name (full name) [Some-State]:hangzhou

Locality Name (eg, city) []:hangzhou

Organization Name (eg, company) [Internet Widgits Pty Ltd]:hz ltd

Organizational Unit Name (eg, section) []:rh

Common Name (e.g. server FQDN or YOUR name) []:192.168.2.1

Email Address []:[email protected]

zhuruhongdeMacBook-Pro:ios zhuruhong$

zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo cp server.* /etc/apache2/

zhuruhongdeMacBook-Pro:ios zhuruhong$

zhuruhongdeMacBook-Pro:apache2 zhuruhong$
sudo apachectl configtest

Syntax OK

zhuruhongdeMacBook-Pro:apache2 zhuruhong$
sudo apachectl restart

zhuruhongdeMacBook-Pro:apache2 zhuruhong$

2-配置apache,开启ssl

编辑/etc/apache2/httpd.conf文件,去掉下面三行前面的#号

(/etc/apache2/httpd.conf和/private/etc/apache2/httpd.conf其实是同一个内容)

LoadModule ssl_module libexec/apache2/mod_ssl.so

Include /etc/apache2/extra/httpd-ssl.conf

Include /etc/apache2/extra/httpd-vhosts.conf

编辑/etc/apache2/extra/httpd-ssl.conf文件,去掉下面两行前面的#号

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

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

编辑/etc/apache2/extra/httpd-vhosts.conf文件,在NameVirtualHost*:80后面添加一段如下内容:

<VirtualHost *:443>

SSLEngine on

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile /etc/apache2/server.crt

SSLCertificateKeyFile /etc/apache2/server.key

ServerName 192.168.2.1

DocumentRoot "/Library/WebServer/Documents"

</VirtualHost>

其中server.crt和server.key就是最开始制作的签名证书。

我这边是放在apache的安装目录(/etc/apache2/)中的,以上不同的配置各自自己注意目录。

到这里就配置完成了,运行sudo apachectl configtest命令,检查配置。

没有问题就可以重启apache,让配置生效了。

碰到的问题:

用sudo apachectl configtest命令检查配置时,出现下面的提示:

Could not reliably determine the server‘s fully qualified domain name

是因为httpd.conf文件中的ServerName没有配置,处于缺省状态。

只需要在apache安装目录/etc/apache2/httpd.conf文件中启用ServerName配置指令即可。

加上:ServerName localhost:80

apache的配置文件httpd.conf中默认是存在类似的指令的,不过在该指令前添加了#号,注释掉了该句,我们只需要模仿着增加一行,然后重启apache即可。

3-配置ipa下载

静态html页面,内容如下:

ipa.html文件:

zhuruhongdeMacBook-Pro:ios zhuruhong$ cat ipa.html

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">

</head>

<ul>

<li>

<a href="itms-services://?action=download-manifest&url=https://192.168.2.1/ios/KDaijiaDriver_enter.plist">local-iOS代驾司机1.0体验版</a>

</li>

</ul>

</html>

plist文件:

zhuruhongdeMacBook-Pro:ios zhuruhong$ cat KDaijiaDriver_enter.plist

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>items</key>

<array>

<dict>

<key>assets</key>

<array>

<dict>

<key>kind</key>

<string>software-package</string>

<key>url</key>

<string>https://192.168.2.1:443/ios/KDaijiaDriver_1.0.0_10020.ipa</string>

</dict>

</array>

<key>metadata</key>

<dict>

<key>bundle-identifier</key>

<string>com.kuaidi.liangjian</string>

<key>bundle-version</key>

<string>1.0</string>

<key>kind</key>

<string>software</string>

<key>title</key>

<string>快的代驾司机端_体验版_10020</string>

</dict>

</dict>

</array>

</dict>

</plist>

以下是相关文件信息:

zhuruhongdeMacBook-Pro:ios zhuruhong$ pwd

/Library/WebServer/Documents/ios

zhuruhongdeMacBook-Pro:ios zhuruhong$ ls -lrt

total 38112

[email protected] 1 zhuruhong  wheel       412  6 18 19:25 ipa.html

-rw-r--r--  1 root       wheel       963  6 19 15:49 app.key

-rw-r--r--  1 root       wheel       757  6 19 15:51 app.csr

-rw-r--r--  1 root       wheel       887  6 19 15:51 server.key

-rw-r--r--  1 root       wheel      1294  6 19 15:51 server.crt

-rw-r--r--  1 zhuruhong  wheel  19486293  6 19 17:33 KDaijiaDriver_1.0.0_10020.ipa

[email protected] 1 zhuruhong  wheel       775  6 19 17:36 KDaijiaDriver_enter.plist

zhuruhongdeMacBook-Pro:ios zhuruhong$

注意:在点击下载前,需要点击server.crt,并信任在手机上安装。

时间: 2024-08-03 23:34:49

mac中apache开启https功能,本地发布安装app的相关文章

Apache配置HTTPS功能

apache配置https 一.yum 安装openssl和openssl-devel,httpd-devel 二.生成证书(也可以从公司的证书颁发机构获取): #建立服务器密钥  openssl genrsa -des3 1024  > /usr/local/apache/conf/server.key    # 从密钥中删除密码(以避免系统启动后被询问口令) openssl rsa -in /usr/local/apache/conf/server.key > /usr/local/apa

【转】CentOs中Apache开启rewrite模块详解

rewrite是apache环境的一个伪静态功能了,如果我们没有没让Apache开启rewrite功能,网站上所有的rewrite规则都不可使用. centos的配置文件放在: /etc/httpd/conf/httpd.conf 打开文件找到: LoadModule rewrite_module modules/mod_rewrite.so 将前面"#"去掉,如果不存在则添加上句. 如果你的网站是根目录的话:找到 <Directory /> Options FollowS

OpenSSL证书生成及Mac上Apache服务器配置HTTPS(也适用centos)

自签名证书 配置Apache服务器SSL 自己作为CA签发证书 这里是OpenSSL和HTTPS的介绍OpenSSLHTTPS 开启HTTPS配置前提是已在Mac上搭建Apache服务器→Mac上Apache服务器搭建 先在桌面创建个SSL文件夹,用来放生成的私钥证书文件打开终端cd到SSL文件夹cd desktop/SSL 1. 自签名证书 (1) 在SSL文件夹中生成私钥 (2) 生成自签名证书 Common Name应该与域名保持一致(如我的电脑搭建的服务器IP地址为192.168.1.1

Ubuntu下配置apache开启https

一.HTTPS简述随着网络的日常,信息安全越来越重要,传统的网站都是http协议明文传输,而HTTPS协议是由SSL+HTTP协议构建的可进行加密传输.身份认证的网络协议,比http协议安全. 那https到底是怎么开启的,随着疑问自己也了解https配置原理并在Ubuntu服务器上开启了https. 二.配置证书 配置https一个很重要的步骤就是配置证书. 1.创建证书 sudo apt-get install ssl-cert make-ssl-cert生成证书的方法有两种,一种是根据生成

Apache开启压缩功能

起源 在一般的web服务器中,都会开启压缩功能,也就是deflate或者是gzip的压缩. 开启压缩功能主要的目的是为了减少传输的带宽,从而当服务器响应给客户端的时候,会大大减少传输的数据,代价就是在服务器段需要消耗cpu时钟周期,因为压缩是在服务器端进行的,并且压缩还是比较损耗cpu的. 在进行压缩的时候,一般压缩的都是静态文件,例如图片,js,css文件. 例如下面几个淘宝首页的js的压缩情况(第一列是压缩前的数据,第二列是压缩后的数据),压缩的标准是在1KB以下的js文件不会进行压缩,大于

apache 开启压缩功能

apache如何开启压缩功能. 1,首先先确认是安装deflatte模块.如果未安装,可以重新编译apache添加参数--enable-deflate=shared ,或者扩展安装deflate模块,如何安装扩展模块可参考链接:http://www.cnblogs.com/lin1/p/5648589.html apachectl -M  可以看到已经安装了defalte模块的. 2,修改配置文件,添加如下信息. <IfModule mod_deflate.c>DeflateCompressi

OpenSSL配置Apache的https功能

https:会话建立过程1.客户端和服务器端先三次握手2.客户端发起请求,请求服务器端的443端口.3.双方协商建立ssl会话4.协商完成后,服务器发送自己的证书给客户端.5.客户端拿到证书后,查看证书是不是受信任证书颁发机构颁发的,和验证证书是不是完整的.6.客户端传递加密后的对称密码给服务器端.连接建立完成 CA给客户端颁发证书过程1.创建CA   自己生成一对密钥   生成自签名证书2.客户端    生成一对密钥    生成证书颁发请求,.csr    将请求发给CA3.CA端     签

Apache 开启 Https

1. 准备所需工具: 1) apache httpd2.4 浏览 2) Win32 OpenSSL v1.0.2d 浏览 2. 安装 2.1 安装Apache2.4服务 php环境搭建 浏览 2.2 安装OpenSSL 双击Win64OpenSSL-1_0_2d.exe进行安装即可. 3. 生成密钥 进入%OpenSSL%\bin目录 1) 生成密钥 openssl genrsa 1024 > server.key 2) 生成证书请求文件 openssl req -config D:\Progr

Apache开启https

apache 要支持https 必须要有mod_ssl软件 [[email protected] www]# yum install mod_ssl [[email protected] ~]# /etc/init.d/httpd restart 修改防火墙添加443 Centos 6.x 已经提供了预设的ssl机制所需私钥与凭证文件 * /etc/httpd/conf.d/ssl.conf            mod_ssl提供的 Apache 设定文件: * /etc/pki/tls/pr