为了不断提高AEM的安全性,Adobe引入了一个称为“默认SSL”的功能。 其目的是鼓励使用HTTPS连接到AEM实例。
您可以通过单击AEM主屏幕中的相关收件箱消息来开始默认配置SSL。 要进入收件箱,请按屏幕右上角的铃图标。 然后,单击视图All。 这将显示在列表视图中排序的所有警报的列表。
在列表中,选择并打开配置HTTPS警报:
如果收件箱中不存在配置HTTPS警报,您可以通过转到*http://serveraddress:serverport/libs/granite/security/content/sslConfig.html?item=configuration%2Fconfiguressl&_charset_=utf-8*直接导航到HTTPS向导
已为此功能创建名为ssl-service的服务用户。 打开警报后,将引导您完成以下配置向导:
首先,设置存储凭据。 这些是ssl-service系统用户密钥存储的凭据,将包含HTTPS监听器的私钥和信任存储。
输入凭据后,单击页面右上角的下一步。 然后,上传SSL连接的相关私钥和证书。
有关如何生成私钥和用于向导的证书的信息,请参见下面的此过程。
最后,指定HTTPS监听器的HTTPS主机名和TCP端口。
默认情况下,有三种方法可自动执行SSL。
第一种方法包括发布到配置向导正在使用的SSLSetup服务器:
POST /libs/granite/security/post/sslSetup.html
您可以在POST中使用以下有效负荷自动配置:
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="keystorePassword"
test
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="keystorePasswordConfirm"
test
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="truststorePassword"
test
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="truststorePasswordConfirm"
test
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="privatekeyFile"; filename="server.der"
Content-Type: application/x-x509-ca-cert
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="certificateFile"; filename="server.crt"
Content-Type: application/x-x509-ca-cert
------WebKitFormBoundaryyBO4ArmGlcfdGDbs
Content-Disposition: form-data; name="httpsPort"
8443
Servlet与任何slingPOSTservlet一样,将以200 OK或错误HTTP状态代码做出响应。 您可以在响应的HTML正文中查找有关状态的详细信息。
以下是成功响应和错误的示例。
成功示例 (status = 200):
<!DOCTYPE html>
<html lang='en'>
<head>
<title>OK</title>
</head>
<body>
<h1>OK</h1>
<dl>
<dt class='foundation-form-response-status-code'>Status</dt>
<dd>200</dd>
<dt class='foundation-form-response-status-message'>Message</dt>
<dd>SSL successfully configured</dd>
<dt class='foundation-form-response-title'>Title</dt>
<dd>OK</dd>
<dt class='foundation-form-response-description'>Description</dt>
<dd>HTTPS has been configured on port 8443. The private key and
certificate were stored in the key store of the user ssl-service.
Please take note of the key store password you provided. You will need
it for any subsequent updating of the private key or certificate.</dd>
</dl>
<h2>Links</h2>
<ul class='foundation-form-response-links'>
<li><a class='foundation-form-response-redirect' href='/'>Done</a></li>
</ul>
</body>
</html>
错误示例 (status = 500):
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Error</title>
</head>
<body>
<h1>Error</h1>
<dl>
<dt class='foundation-form-response-status-code'>Status</dt>
<dd>500</dd>
<dt class='foundation-form-response-status-message'>Message</dt>
<dd>The provided file is not a valid key, DER format expected</dd>
<dt class='foundation-form-response-title'>Title</dt>
<dd>Error</dd>
</dl>
</body>
</html>
或者,您也可以通过上传已包含这些必需项的包来自动设置SSL:
GraniteSslConnectorFactory
配置在下面,您将找到一个示例,用于创建SSL向导可使用的DER格式的自签名证书。 根据操作系统安装OpenSSL,打开OpenSSL命令提示符,并将目录更改为要在其中生成私钥/证书的文件夹。
自签名证书的使用仅用于示例目的,不应用于生产。
首先,创建私钥:
openssl genrsa -aes256 -out localhostprivate.key 4096
openssl rsa -in localhostprivate.key -out localhostprivate.key
然后,使用私钥生成证书签名请求(CSR):
openssl req -sha256 -new -key localhostprivate.key -out localhost.csr -subj "/CN=localhost"
生成SSL证书并使用私钥对其进行签名。 在此示例中,将从现在起一年过期:
openssl x509 -req -days 365 -in localhost.csr -signkey localhostprivate.key -out localhost.crt
将私钥转换为DER格式。 这是因为SSL向导要求密钥采用DER格式:
openssl pkcs8 -topk8 -inform PEM -outform DER -in localhostprivate.key -out localhostprivate.der -nocrypt
最后,在本页开头所述的图形SSL向导的步骤2中,将localhostprivate.der作为私钥上传,将localhost.crt作为SSL证书上传。
有关AEM中有用的cURL命令的集中列表,请参阅将cURL与AEM一起使用。
您还可以使用cURL工具自动进行SSL配置。 您可以通过将配置参数发布到此URL来执行此操作:
https://<serveraddress>:<serverport>/libs/granite/security/post/sslSetup.html
下面是在配置向导中更改各种设置时可以使用的参数:
-F "keystorePassword=password"
-密钥库密码;
-F "keystorePasswordConfirm=password"
-确认密钥库密码;
-F "truststorePassword=password"
-信任商店密码;
-F "truststorePasswordConfirm=password"
-确认信任商店密码;
-F "privatekeyFile=@localhostprivate.der"
-指定私钥;
-F "certificateFile=@localhost.crt"
-指定证书;
-F "httpsHostname=host.example.com"
-指定主机名;
-F "httpsPort=8443"
- HTTPS监听器将使用的端口。
运行cURL以自动进行SSL配置的最快方式来自DER和CRT文件所在的文件夹。 或者,也可以在privatekeyFile
和certificateFile参数中指定完整路径。
您还需要通过身份验证才能执行更新,因此请确保在cURL命令后面附加-u user:passeword
参数。
正确的cURL post命令应当如下:
curl -u user:password -F "keystorePassword=password" -F "keystorePasswordConfirm=password" -F "truststorePassword=password" -F "truststorePasswordConfirm=password" -F "privatekeyFile=@localhostprivate.der" -F "certificateFile=@localhost.crt" -F "httpsHostname=host.example.com" -F "httpsPort=8443" https://host:port/libs/granite/security/post/sslSetup.html
可以通过重复certificateFile参数,将证书链发送给servlet,如下所示:
-F "certificateFile=@root.crt" -F "certificateFile=@localhost.crt"..
执行命令后,请验证所有证书是否都已发送到密钥库。 从以下位置检查密钥库:
http://localhost:4502/libs/granite/security/content/userEditor.html/home/users/system/security/ssl-service