简体   繁体   English

如何使用 keytools 将我的 VPS SSL 证书导入到我的码头密钥库中?

[英]How do I import my VPS SSL certificate into my jetty keystore using keytools?

I have written a webapp in B4J, which is a Basic language IDE that compiles the app to an executable java jar.我用 B4J 编写了一个 webapp,它是一个基本语言 IDE,可将应用程序编译为可执行的 java jar。 My webapp works fine on http but I now need to embed it into a WordPress page, which I do using an iframe plugin for WordPress.我的 web 应用程序在 http 上运行良好,但我现在需要将它嵌入到 WordPress 页面中,我使用 WordPress 的 iframe 插件。

The WordPress site runs on http s so I therefore need to have my webapp run on https.在http S上的WordPress站点运行,从而因此,我需要对我的HTTPS Web应用程序运行。 I've searched the B4J forum and successfully converted the webapp so that the embedded jetty server starts up and connects on https but I am now in the world of SSL, which I have never had to deal with before.我搜索了 B4J 论坛并成功转换了 webapp,以便嵌入式码头服务器启动并通过 https 连接,但我现在处于 SSL 的世界,我以前从未处理过这种情况。

I've followed various howto's and tutorials and successfully created a self-signed SSL cert using 'keytool' and that has allowed me to test and prove that my webapp is running under https.我遵循了各种操作方法和教程,并使用“keytool”成功创建了一个自签名 SSL 证书,这使我能够测试并证明我的 web 应用程序是在 https 下运行的。 However the time has come for me upgrade the SSL cert to 'proper' certification so that the webapp can run without the browser warnings caused by the self-signed cert.然而,现在是我将 SSL 证书升级为“正确”认证的时候了,这样 webapp 就可以运行,而不会出现由自签名证书引起的浏览器警告。

So this is where my SSL ability becomes super-thin... My VPS host is HostGator (HG) and the VPS plan comes with a free SSL cert that is periodically renewed.所以这就是我的 SSL 能力变得超薄的地方...我的 VPS 主机是 HostGator (HG) 并且 VPS 计划附带一个定期更新的免费 SSL 证书。 The HG cert covers the domain that both the WordPress site and the webapp will run on. HG 证书涵盖 WordPress 站点和 web 应用程序将在其上运行的域。 I have asked HG Support whether their free cert would cover my webppp and they seem to think that it would but I need to make it available to the webapp when the java jar starts up the Jetty server.我已经问过 HG Support 他们的免费证书是否会涵盖我的 webppp,他们似乎认为会,但我需要在 java jar 启动 Jetty 服务器时将其提供给 webapp。 To that end I would like to try and import the HG cert into my Jetty keystore file and see it it will work.为此,我想尝试将 HG 证书导入到我的 Jetty 密钥库文件中,看看它会起作用。 My problem is that I am unsure about:我的问题是我不确定:

  • Where the HG SSL cert is or what it looks like; HG SSL 证书的位置或外观; and
  • How to actually import the HG SSL Cert into my Jetty keystore如何将 HG SSL 证书真正导入我的 Jetty 密钥库

I have read various threads both on B4J forum and StackOverflow but I'm not confident at this point that I know what I'm doing.我已经阅读了 B4J 论坛和 StackOverflow 上的各种主题,但此时我对自己知道自己在做什么没有信心。 I would greatly appreciate any assistance given and can supply the following information to help.我将不胜感激所提供的任何帮助,并可以提供以下信息来提供帮助。

  • I can view the HG SSL certs on the HG VPS WHM panel.我可以在 HG VPS WHM 面板上查看 HG SSL 证书。 It covers the domain I am using.它涵盖了我正在使用的域。
  • I created my Jetty keystore (self-signed) using 'keytool'我使用“keytool”创建了我的 Jetty 密钥库(自签名)
  • The jetty keystore (called jetty.keystore) is stored in the root directory of the webapp. jetty 密钥库(称为 jetty.keystore)存储在 web 应用程序的根目录中。
  • The jetty.keystore has storetype PKCS12, which the process prompted me to do when I created it. jetty.keystore 的 storetype 为 PKCS12,当我创建它时,进程提示我这样做。

Having search some Linux forums I am pretty sure that the HG SSL cert is in a file located in:搜索了一些 Linux 论坛后,我很确定 HG SSL 证书位于以下位置的文件中:

  • /etc/pki/tls/certs /etc/pki/tls/certs
  • in that directory are links to ca-bundle.crt and ca-bundle.trust.crt;在该目录中是指向 ca-bundle.crt 和 ca-bundle.trust.crt 的链接; and
  • a file called mydomain.com .一个名为mydomain.com的文件。 crt资源管理器

So...my question is:所以......我的问题是:

  • is mydomain.com .mydomain.com crt likely to be the HG VPS free domain SSL cert? crt可能是 HG VPS 免费域 SSL 证书?
  • If so, how do I go about importing that cert into my jetty.keystore file?如果是这样,我该如何将该证书导入到我的 jetty.keystore 文件中?

Solution:解决方案:

  • Using Developer tools in Chrome...View the SSL Certificate and Private Key for the domain.使用 Chrome 中的开发人员工具...查看域的 SSL 证书和私钥。
  • Locate both of these files on the VPS, which were under the domain owners account, not the root account.在 VPS 上找到这两个文件,它们位于域所有者帐户下,而不是根帐户下。
  • Make sure the cert and PK match the ones displayed in Chrome Developer Tools view.确保证书和 PK 与 Chrome 开发人员工具视图中显示的相匹配。
  • keytool -genkey -keyalg RSA -alias jetty -keystore jetty.keystore -keysize 2048 keytool -genkey -keyalg RSA -alias jetty -keystore jetty.keystore -keysize 2048
  • Enter the prompted answers.输入提示的答案。
  • keytool -delete -alias jetty -storepass keystore-password-value -keystore jetty.keystore keytool -delete -alias jetty -storepass keystore-password-value -keystore jetty.keystore
  • keytool -list -storepass keystore-password-value -keystore jetty.keystore (to check that the key store is empty) keytool -list -storepass keystore-password-value -keystore jetty.keystore (检查密钥库是否为空)
  • openssl pkcs12 -export -in /../../cert-directory/certificate-file.crt -inkey /../../cert-directory/pk-file.key -name host -out outfile.p12 openssl pkcs12 -export -in /../../cert-directory/certificate-file.crt -inkey /../../cert-directory/pk-file.key -name host -out outfile.p12
  • keytool -importkeystore -deststorepass keystore-password-value -destkeystore jetty.keystore -srckeystore outfile.p12 -srcstoretype PKCS12 keytool -importkeystore -deststorepass keystore-password-value -destkeystore jetty.keystore -srckeystore outfile.p12 -srcstoretype PKCS12

Answer added on behalf of OP代表 OP 添加的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM