我正在尝试在本地测试API网关证书,以提供概念证明而没有运气。
我创建了一个localhost IIS服务器,并使用以下帮助页面(由AWS支持团队提供)对其进行配置:
简而言之,我的IIS设置为使用具有
的测试网站server certificate
IIS Express Development Certificate
尝试直接访问该网站会给我预期的结果:
然后我从API网关生成新证书
我将此证书的密钥(复制/粘贴)保存到.cer文件(我也尝试过.pem和.crt文件)
然后我尝试通过以下应用程序调用相同的https://localhost:8000传递证书:
所有不成功 - 我从Postman得到的结果是:
注意:我已经知道这个错误是由邮递员本机应用程序同时需要CRT文件和证书的KEY文件(API Gateway只给我crt文件)这一事实驱动的。
来自cURL的命令和结果是:
curl --cert' C:。pemPath' https://localhost:8000
我迄今为止使用的一些参考页面(还有一些未添加):
有人有想法吗?
答案 0 :(得分:2)
是否需要针对IIS进行测试?我最近用nginx完成了类似的练习:
1)在AWS EC2实例上设置Ngnix服务器。 https://www.nginx.com/blog/setting-up-nginx/
2)从LetsEncrypt安装免费的SSL证书。 https://certbot.eff.org/#ubuntuxenial-nginx
ubuntu@host:~$ sudo certbot --nginx
3)上传AWS API Gateway生成的证书(API Gateway> Client Certificates> Copy)。
4)配置Nginx以启用客户端ssl身份验证ssl_client_certificate
和ssl_verify_client
ubuntu@host:/etc/nginx$ cat nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name your-domain.com;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
root /usr/share/nginx/html;
ssl_client_certificate /home/ubuntu/client.crt; # this file should contain Client Certificate
ssl_verify_client on;
index index.html;
}
include /etc/nginx/conf.d/*.conf;
}
这就是行为
# when no certificate provider (direct call to backend)
<center><h1>400 Bad Request</h1></center>
<center>No required SSL certificate was sent</center>
# via api gateway with valid client certificate
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
#via api gateway with invalid client certificate
<center><h1>400 Bad Request</h1></center>
<center>The SSL certificate error</center>