测试环境搭建:
1.服务器主机
·安装 ubuntu20.04 server系统
·安装 nginx
·安装 WebAuthn后端服务
2.客户机
·安装 window10系统
·安装 Edge浏览器
3.OpenSK加密U盘
详细步骤:
1.在服务器上安装ubuntu20.04 server系统(详细步骤参考ubuntu官网)
2.安装nginx,详细步骤参照以下链接
注意:nginx必须配置成https,否则WebAuthn无法使用
·配置nginx代理
nano /etc/nginx/sites-available/default
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://127.0.0.1:8080;
# try_files $uri $uri/ =404;
}
·配置完成重新加载nginx配置
sudo service nginx reload
3.安装WebAuthn后端服务,具体步骤参照以下链接GitHub - hbolimovsky/webauthn-example: Basic WebAuthn client and server in go
·修改webauthn-example工程代码
webAuthn, err = webauthn.New(&webauthn.Config{
RPDisplayName: "Foobar Corp.", // Display Name for your site
RPID: "abc", // Generally the domain name for your site
RPOrigin: "http://localhost", // The origin URL for WebAuthn requests
// RPIcon: "https://duo.com/logo.png", // Optional icon URL for your site
})
注意:修改RPID为“abc”,“abc”为WebAuthn后端服务的域名,在WebAuthn中RPID必须为域名,不能为IP地址。
·编译WebAuthn后端服务,编译需要go环境,需先安装go
go build
·运行WebAuthn后端服务
./webauthn-example
fox@fox:~/wb/webauthn-example$ go build
fox@fox:~/wb/webauthn-example$ ./webauthn-example
2021/12/23 02:44:45 starting server at :8080
4.OpenSK加密U盘制作
硬件选择和软件写入,见如下教程:
OpenSK/nrf52840_dongle.md at stable · google/OpenSK · GitHub
5.配置window10电脑本地DNS服务器
修改文件C:\Windows\System32\drivers\etc\hosts
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
192.168.0.62 abc
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
注意:WebAuthn服务器ip为192.168.0.62
6.最后测试
·将OpenSK加密U盘插入Window10电脑,然后打开Edge浏览器,输入https://abc,然后显示测试网页。