使用 makecert 向自签名证书添加或创建“主题备用名称"字段

本文介绍了使用 makecert 向自签名证书添加或创建“主题备用名称"字段的处理方法,对大家解决问题具有一定的参考价值

问题描述

如何使用带有主题备用名称"字段的 makecert 创建证书?

How can I create a certificate using makecert with a 'Subject Alternative Name' field ?

您可以添加 一些 字段,例如使用 -eku 选项的增强型密钥使用",我尝试了 -san 选项,但 makecert 不喜欢它.

You can add some fields eg, 'Enhanced Key Usage' with the -eku option and I've tried the -san option but makecert doesn't like it.

这是一个自签名证书,因此任何使用 IIS 创建内容以发送给 CA 的方法都不合适.

This is a self-signed certificate so any method that uses IIS to create something to send off to a CA won't be appropriate.

推荐答案

Makecert 似乎不支持 SAN,所以我创建了一个带有 SAN 的证书,用于使用 OpenSSL 的 IIS.查看我的博客文章:

Makecert doesn't appear to support SANs so I created a certificate with SANs for use with IIS using OpenSSL. Check out my blog post about it:

IIS 7 提供了一些易于使用的向导来创建 SSL 证书,但是不是很强大.我需要做的是创建 SSL包含 x.509 V3 扩展的证书,即主题替代名称,a.k.a SAN.SAN 所做的是允许网站用于验证来自多个 URL 域的传入请求的证书名称.当 web 服务器运行 web 时,这非常重要服务(例如 WCF 服务)以及其他 Web 服务何时连接到它们通过 SSL 连接与面向服务的体系结构一样.除非向 Web 服务添加特殊代码来覆盖默认 SSL 验证处理程序例程,通用名称 (CN)证书必须与传入的请求 URL 域匹配.所以如果请求是使用 FQDN 发出的,证书的 FQDN 必须为CN 或 SAN、IP 地址或仅主机名将导致 SSL验证错误,连接将失败.

IIS 7 provides some easy to use wizards to create SSL certificates, however not very powerful ones. What I needed to do was to create SSL certificates that included a x.509 V3 extension, namely subject alternative names, a.k.a SANs. What SANs do is allow the website certificate to validate incoming requests by more than one URL domain name. This is really important when the web server is running web services such as WCF services and when other web services connect to them over SSL connections as with service oriented architectures. Unless special code is added to the web services to override the default SSL validation handler routines, the common name (CN) of the certificate MUST match the incoming request URL domain. So if the request was made using an FQDN, the certificate must have the FQDN as a CN or a SAN, a IP address or just a hostname will cause an SSL validation error and the connection will fail.

SAN 来拯救... SAN 支持 DNS 名称和 IP 等地址.因此,通过使用服务器 FQDN 的 SAN 创建证书和 IP 地址,它增加了其他 Web 服务可以使用的方式连接.

SANs to the rescue… SANs support, among other things, DNS names and IP addresses. So by creating the certificate with SANs of the server FQDN and IP address, it increases the ways that other web services can connect.

有许多工具可以生成证书:makecert.exe、keytool.exe (java)、selfssl.exe 和 openssl.exe.在此外,从 Windows Vista 和 Server 2008 开始,Microsoft 添加了CertEnroll API,它也可以以编程方式创建证书通过 COM 接口.

There are a number of tools that can generate certificates: makecert.exe, keytool.exe (java), selfssl.exe and openssl.exe. In addition, starting with Windows Vista and Server 2008 Microsoft added the CertEnroll API which can also create certificates programmatically either through COM interfaces.

OpenSSL 最终完成了我需要它做的事情.这个过程是相当直截了当.

OpenSSL ended up doing exactly what I needed it to do. The process was fairly straight forward.

  1. 构造一个 OpenSSL 配置文件.

[req] distinct_name = req_distinguished_name x509_extensions =v3_req prompt = no [req_distinguished_name] C = US ST = VA L =某处 O = MyOrg OU = MyOU CN = MyServerName [v3_req] keyUsage =keyEncipherment, dataEncipherment extendedKeyUsage = serverAuthsubjectAltName = @alt_names [alt_names] DNS.1 = MyServerName DNS.2 =10.0.1.34 IP.1 = 10.0.1.34 IP.2 = 192.167.20.1

[req] distinguished_name = req_distinguished_name x509_extensions = v3_req prompt = no [req_distinguished_name] C = US ST = VA L = Somewhere O = MyOrg OU = MyOU CN = MyServerName [v3_req] keyUsage = keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth subjectAltName = @alt_names [alt_names] DNS.1 = MyServerName DNS.2 = 10.0.1.34 IP.1 = 10.0.1.34 IP.2 = 192.167.20.1

  1. 使用 OpenSSL 创建 x509 请求

openssl.exe req -x509 -nodes -days 730 -newkey rsa:2048 -keyoutC:cert.pem -out C:cert.pem -config C:PathToConfigFileAbove.txt

openssl.exe req -x509 -nodes -days 730 -newkey rsa:2048 -keyout C:cert.pem -out C:cert.pem -config C:PathToConfigFileAbove.txt

  1. 创建一个包含密钥对的 PFX

openssl.exe pkcs12 -export -out C:cert.pfx -in C:cert.pem -name "My证书"-passout pass:mypassword

openssl.exe pkcs12 -export -out C:cert.pfx -in C:cert.pem -name "My Cert" -passout pass:mypassword

  1. 使用服务器中的导入链接将 PFX 导入 IIS证书区.

  1. Import the PFX into IIS using the import link in the server certificates area.

将证书绑定到 IIS 网站.

Bind the certificate to the IIS websites.

还有 viola,我们知道有一个带有 SAN 的 IIS 的 SSL 证书,所以我们可以使用多个域名连接而无需证书验证错误.

And viola, we know have a SSL certificate for IIS with SANs so we can connect using multiple domain names without certificate validation errors.

来源:使用 SAN 创建证书使用 OpenSSL,作者 Andy Arismeti,2011 年 9 月 1 日,星期四

Source: Creating certificates with SANs using OpenSSL by Andy Arismeti, Thursday, September 1, 2011

这篇关于使用 makecert 向自签名证书添加或创建“主题备用名称"字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1170

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1070

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this->id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:806

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this->id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:899

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:930

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:877

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:864

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:834

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1726

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1308