root
用户进行操做这里咱们使用https://github.com/Fishdrowned/ssl提供的shell脚本生成ssl证书,在命令行中输入如下命名:html
git clone https://github.com/Fishdrowned/ssl.git #将项目下载到本地
项目的目录结构以下:git
. ├── LICENSE ├── README.md ├── ca.cnf ├── docs │ ├── chrome-certs-details.png │ ├── chrome-certs-ok.png │ ├── chrome-settings-certs-imported.png │ ├── chrome-settings-certs.png │ ├── chrome-trust.md │ └── output.png ├── flush.sh ├── gen.cert.sh └── gen.root.sh
若是须要修改CA、证书相关信息,能够编辑ca.cnf
和gen.cert.sh
替换对应的内容。接下来,输入如下命令生成ssl证书,github
./gen.cert.sh registry.anxminise.cc #生成registry.anxminise.cc域名的证书
目录中,会生成一个out
目录,里面的registry.anxminise.cc
目录存放了生成的证书,内容以下:chrome
. ├── 20181011-0710 │ ├── registry.anxminise.cc.bundle.crt │ ├── registry.anxminise.cc.crt │ └── registry.anxminise.cc.csr.pem ├── registry.anxminise.cc.bundle.crt -> ./20181011-0710/registry.anxminise.cc.bundle.crt ├── registry.anxminise.cc.crt -> ./20181011-0710/registry.anxminise.cc.crt ├── registry.anxminise.cc.key.pem -> ../cert.key.pem └── root.crt -> ../root.crt
其中,registry.anxminise.cc.crt
是咱们须要的证书,registry.anxminise.cc.key.pem
是秘钥存储文件,将这两个文件上传到Harbor服务器,这里是192.168.1.112
服务器。shell
Harbor服务器上执行如下命令vim
mkdir -p /data/cert建立证书存放目录 mv registry.anxminise.cc.crt /data/cert/server.crt #将证书放到Harbor配置目录下 mv registry.anxminise.cc.key.pem /data/cert/server.key #将秘钥放到Harbor配置目录下 ll /data/cert #查看目录内容
cd /opt/harbor #进入到harbor目录 vim harbor.cfg #编辑harbor的配置文件
编辑如下内容:windows
hostname = registry.anxminise.cc #配置harbor服务器的域名 ui_url_protocol = https #配置https方式启动
./prepare #从新配置Harbor ./install.sh #从新执行Harbor安装,注:此处可能有更好的方式重启
编辑本地的/etc/hosts
文件,加入registry.anxminise.cc
域名,以下:centos
vim /etc/hosts #编辑hosts文件
文件最后添加以下内容:浏览器
192.168.1.112 registry.anxminise.cc
保存并退出服务器
打开钥匙串访问
应用,添加生成的根证书,以下:
并设置证书为始终信任,以下:
待补充
浏览器中输入https://registry.anxminise.cc
,以下: