- Generating self-signed certificates on Windows
- 1. PowerShell 4.0
- 2. OpenSSL
- 3. Makecert
- 4. Selfssl7
- 5. IIS
- 6. Pluralsight
- 7. SelfSSL
- 8. SSLChecker
- 9. Hard core
- 10. mkcert
- Создание нового сертификата Exchange Server самозаверяемого сертификата Create a new Exchange Server self-signed certificate
- Что нужно знать перед началом работы What do you need to know before you begin?
- Создать самозаверяющий сертификат Exchange с помощью Центра администрирования Exchange Use the EAC to create a new Exchange self-signed certificate
- Создать самозаверяющий сертификат Exchange с помощью командной консоли Exchange Use the Exchange Management Shell to create a new Exchange self-signed certificate
- Как убедиться, что все получилось? How do you know this worked?
Generating self-signed certificates on Windows
If you do anything with Identity, you’ll know you need certificates — lots of them — and that normally means self-signed to keep the costs down or because you just need it for a short time before you tear down the VM or because you don’t have a PKI infrastructure.
This is for testing, proofs of concept etc. This is definitely not for Production purposes. Use at your own risk.
This self-signed certificate also needs a private key otherwise it’s pretty useless for SSL, token signing etc.
Remember that this won’t be signed by a CA so you need to do this to stop the browser complaining once you’ve generated the certificates.
Note: The “ character displayed by Medium does something funny when you cut and paste and run the command. You need to retype it as a “straight” character.
Just calling out Let’s Encrypt. They provide free CA certificates that support multiple SAN and wildcards. The drawback is that the certificate is only valid for 90 days but they provide an automated renew process. This is a very good option for a quick PoC.
So, what other options do we have?
1. PowerShell 4.0
Running as administrator.
$cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname company.co.nz
Using “mmc”, we can see the certificate in the local computer store. Although it shows “Client Authentication”, it is valid for “Server Authentication” as well.
Now we can do the normal export function or we can create the pfx file ourselves.
$pwd = ConvertTo-SecureString -String ‘password1234’ -Force -AsPlainText
$path = ‘cert:\localMachine\my\’ + $cert.thumbprint
Export-PfxCertificate -cert $path -FilePath c:\junk\certificate\powershellcert.pfx -Password $pwd
and then double-click the pfx file to import via the “Certificate Import Wizard”. You’ll be asked to input the password you used above.
This certificate is only valid for a year (the default).
If we wanted a three-year certificate, we need:
$date_now = Get-Date
$extended_date = $date_now.AddYears(3)
$cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname company.co.nz -notafter $extended_date
Now what happens if we need multiple SAN (subject alternative name)?
“-DnsName” specifies one or more DNS names to put into the subject alternative name extension of the certificate. The first DNS name is also saved as the Subject Name.
$cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname company.co.nz, mycompany.co.nz, minecompany.co.nz -notafter $extended_date -KeyLength 4096
And note the keylength parameter if that’s something you need to change.
2. OpenSSL
Originally for the Linux world but you can get a Windows version from Shining Light. Don’t worry about the Win32 reference and the outdated documentation at the top. Scroll down and you’ll see the latest Win64 stuff.
And help with future work by donating $10 😄. It’s a lot easier than having to compile the binaries!
openssl version -a
gives you the version.
openssl req -x509 -newkey rsa:4096 -sha256 -keyout openssl.key -out openssl.crt -subj “/CN=company.co.nz” -days 600
Generating a 4096 bit RSA private key
…………………………………++
…………………………++
writing new private key to ‘opensll.key’
Enter PEM pass phrase:
Verifying — Enter PEM pass phrase:
The crt file is the same as a cer file. You can use it in Windows e.g. to load a signing key for another claims provider in ADFS.
But it doesn’t contain a private key — that’s in a separate file — and Windows doesn’t like that. See below for steps on combining them.
As far as multiple SAN are concerned, OpenSSL currently doesn’t support a way of doing this via the command line.
I believe this is coming in 1.1.1 via:
extension “subjectAltName = DNS:mycompany.co.nz, DNS:minecompany.co.nz”
At the moment, you need to do this via a configuration file.
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = NZ
ST = NI
L = Auckland
O = Company
OU = Division
CN = company.co.nz
[v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = company.co.nz
DNS.2 = mycompany.com
DNS.3 = minecompany.co.nz
Save this as “san.cnf”.
openssl req -x509 -newkey rsa:4096 -sha256 -keyout opensll.key -out openssl.crt -days 600 -config san.cnf
To make this available to Windows, you need to combine the private and public keys into one pfx file.
openssl pkcs12 -export -name “company.co.nz” -out openssl.pfx -inkey openssl.key -in openssl.crt
where “company.co.nz” is the friendly name.
3. Makecert
As per the documentation, makecert is deprecated and you should use the PowerShell command as above.
Official documentation is here.
To make a self-signed certificate with a private key, use:
makecert -r -pe -n “CN=company.co.nz” -e 01/01/2019 -sky exchange -sv makecert.pvk makecert.cer
“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\pvk
2pfx.exe” -pvk makecert.pvk -spc makecert.cer -pfx makecert.pfx
(The path to pvk2pfx is as per my PC. YMMV).
Then install the pfx file.
4. Selfssl7
This used to be my go-to tool for generating self-signed certificates.
The current version runs on .NET 3.5 that is not normally installed on the latest servers and PC’s. You can download the code and rebuild for .NET 4.6 and it will work just fine.
One of the best features for me was that it could do the IIS SSL bindings as well as installing the certificate into the appropriate store.
SelfSSL7 /N cn=company.co.nz /K 2048 /V 3652 /X /F c:cert.pfx
This generates a self-signed certificate using a 2048 bit-length key, without a password in .pfx format (including the private key)
5. IIS
This is one of those hidden features that very few people know about.
From the top-level in IIS Manager, select “Server Certificates”.
Then click the “Create” on the right.
This will create a self-signed certificate valid for a year with a private key. It is only for “localhost”.
6. Pluralsight
Yes, they are a training company but they also have some neat utilities.
You can create a PFX file directly or you can save directly to a certificate store of your choice.
7. SelfSSL
This is an old-school utility which is available if you have the Microsoft Internet Information Services (IIS) 6.0 Resource Kit.
selfssl /t /v:200 /n:cn=company.co.nz
The /t option saves you a step by automatically installing the new self-signed SSL certificate into the Web server’s certificate store. The /v option specifies the number of days the certificate will be valid.
8. SSLChecker
This is an online utility.
This will generate a self-signed certificate and a private key in the format:
Save the two texts; call the certificate file “something.crt” and call the private key file “something.key” then use the openssl command above to combine both into a .pfx file that you can then import.
9. Hard core
If you are a developer and insist on rolling your own, there are a number of examples around. .NET doesn’t have the required support so you need to use Bouncy Castle.
10. mkcert
mkcert is a simple tool for making locally-trusted development certificates. It requires no configuration.
“mkcert is written in Go, and you can run it with a Go run command”.
If you have another utility you recommend, note it in a comment and I’ll add it.
The traditional way to look at certificates is to “Run mmc”.
Создание нового сертификата Exchange Server самозаверяемого сертификата Create a new Exchange Server self-signed certificate
При установке Exchange Server на сервере автоматически устанавливается самозаверяется сертификат, созданный и подписанный самим сервером Exchange. When you install Exchange Server, a self-signed certificate that’s created and signed by the Exchange server itself is automatically installed on the server. Но вы также можете создать и использовать дополнительные самозаверяющие сертификаты. However, you can also create additional self-signed certificates that you can use.
Вы можете создавать самозаверяющие сертификаты в Центре администрирования Exchange (EAC) или командной консоли Exchange. You can create self-signed certificates certificate in the Exchange admin center (EAC) or in the Exchange Management Shell.
Что нужно знать перед началом работы What do you need to know before you begin?
Предполагаемое время для завершения: 5 минут. Estimated time to complete: 5 minutes.
Самозаверяющие сертификаты Exchange хорошо работают для шифрования связи между внутренними серверами Exchange, но не так хорошо для шифрования внешних подключений, так как клиенты, серверы и службы автоматически не доверяют самозаверяемо подписанным сертификатам Exchange. Exchange self-signed certificates work well for encrypting communication between internal Exchange servers, but not so well for encrypting external connections, because clients, servers, and services don’t automatically trust Exchange self-signed certificates. Чтобы создать запрос сертификата (также известный как запрос на подписание сертификата или CSR) для коммерческого органа сертификации, которому автоматически доверяют все клиенты, серверы и службы, см. в Exchange Server запрос сертификата для органа сертификации . To create a certificate request (also known as a certificate signing request or CSR) for a commercial certification authority that’s automatically trusted by all clients, servers, and services, see Create an Exchange Server certificate request for a certification authority.
При создании нового самозаверяемого сертификата с помощью комлета New-ExchangeCertificate можно назначить сертификат службам Exchange во время создания сертификата. When you create a new self-signed certificate by using the New-ExchangeCertificate cmdlet, you can assign the certificate to Exchange services during the creation of the certificate. Дополнительные сведения о службах Exchange см. в справке Назначение сертификатов Exchange Server службам. For more information about the Exchange services, see Assign certificates to Exchange Server services.
Сведения о том, как открыть командную консоль Exchange в локальной организации Exchange, см. в статье Open the Exchange Management Shell. To learn how to open the Exchange Management Shell in your on-premises Exchange organization, see Open the Exchange Management Shell.
Для выполнения этих процедур необходимы соответствующие разрешения. Сведения о необходимых разрешениях см. в статье запись «Безопасность служб клиентского доступа» в статье Разрешения клиентов и мобильных устройств. You need to be assigned permissions before you can perform this procedure or procedures. To see what permissions you need, see the «Client Access services security» entry in the Clients and mobile devices permissions topic.
Сочетания клавиш для процедур, описанных в этой статье, приведены в статье Сочетания клавиш в Центре администрирования Exchange. For information about keyboard shortcuts that may apply to the procedures in this topic, see Keyboard shortcuts in the Exchange admin center.
Возникли проблемы? Попросите помощи на форумах Exchange. Перейти на форумы можно по следующим ссылкам: Exchange Server, Exchange Online или Exchange Online Protection. Having problems? Ask for help in the Exchange forums. Visit the forums at: Exchange Server, Exchange Online, or Exchange Online Protection.
Создать самозаверяющий сертификат Exchange с помощью Центра администрирования Exchange Use the EAC to create a new Exchange self-signed certificate
В Центре администрирования Exchange последовательно выберите пункты Серверы > Сертификаты. Open the EAC and navigate to Servers > Certificates.
В списке Выберите сервер выберите сервер Exchange, на котором необходимо установить сертификат, а затем нажмите кнопку Добавить . In the Select server list, select the Exchange server where you want to install the certificate, and then click Add .
Запустится мастер Создание сертификата Exchange. На странице Этот мастер создаст новый сертификат или файл запроса на сертификат выберите Создать самозаверяющий сертификат и нажмите кнопку Далее. The New Exchange certificate wizard opens. On the This wizard will create a new certificate or a certificate request file page, select Create a self-signed certificate, and then click Next.
Примечание: Чтобы создать новый запрос сертификата для органа сертификации, см. в Exchange Server запрос сертификата для органа сертификации. Note: To create a new certificate request for a certificate authority, see Create an Exchange Server certificate request for a certification authority.
На странице Понятное имя для этого сертификата введите понятное имя сертификата и нажмите кнопку Далее. On the Friendly name for this certificate page, enter a friendly name for the certificate, and then click Next.
В странице Укажите серверы, которые необходимо применить к этому сертификату, щелкните значок Добавить In the Specify the servers you want to apply this certificate to page, click Add
На открывшейся странице Выберите сервер выберите сервер Exchange, на который необходимо установить сертификат, и нажмите Добавить — >. On the Select a server page that opens, select the Exchange server where you want to install the certificate, and click Add — >. Повторите этот шаг необходимое количество раз. Repeat this step as many times as necessary. По завершению выбора серверов нажмите кнопку ОК. When you’re finished selecting servers, click OK.
По завершении нажмите кнопку Далее. When you’re finished, click Next.
Страница Укажите домены, которые вы хотите включить в свой сертификат это лист, на котором можно определить необходимые имена внутренних и внешних узлов для следующих служб Exchange: The Specify the domains you want to be included in your certificate page is basically a worksheet that helps you determine the internal and external host names that are required in the certificate for the following Exchange services:
Outlook в Интернете Outlook on the web
Формирование автономной адресной книги (OAB) Offline address book generation (OAB)
веб-службы Exchange Exchange Web Services
Exchange ActiveSync Exchange ActiveSync
Мобильный Outlook Outlook Anywhere
Если вы введете значения для каждой службы на основе расположения (внутренней или внешней), мастер определит необходимые имена узлов, и они отобразятся на следующей странице. If you enter a value for each service based on the location (internal or external), the wizard determines the host names that are required in the certificate, and the information is displayed on the next page. Чтобы изменить значение для службы, нажмите кнопку Изменить (изменить значок) и введите значение имени хост, которое вы хотите использовать (или удалить значение). To modify a value for a service, click Edit ( ) and enter the host name value that you want to use (or delete the value). По завершении нажмите кнопку Далее. When you’re finished, click Next.
Если вы уже определили необходимые имена узлов, вам не нужно заполнять поля на этой странице. Вместо этого нажмите кнопку Далее, чтобы вручную ввести имена узлов на следующей странице. If you’ve already determined the host name values that you need in the certificate, you don’t need to fill out the information on this page. Instead, click Next to manually enter the host names on the next page.
В соответствии с вашими выборами на странице сертификата будут включены следующие домены, в которых перечислены имена хостов, которые будут включены в самозаверяемый сертификат. The Based on your selections, the following domains will be included in your certificate page lists the host names that will be included in the self-signed certificate. The host name that’s used in the certificate’s Subject field is bold, which can be hard to see if that host name is selected. The host name that’s used in the certificate’s Subject field is bold, which can be hard to see if that host name is selected. You can verify the host name entries that are required in the certificate based on the selections that you made on the previous page. You can verify the host name entries that are required in the certificate based on the selections that you made on the previous page. Or, you can ignore the values from the last page and add, edit, or remove host name values. Or, you can ignore the values from the last page and add, edit, or remove host name values.
Если требуется сертификат SAN, укажите в поле Subject одно общее имя (CN). Чтобы выбрать имя узла для поля Subject сертификата, выберите значение и установите флажок Задать как общее имя. После этого значение должно быть выделено полужирным шрифтом. If you want a SAN certificate, the Subject field still requires one common name (CN) value. To select the host name for the certificate’s Subject field, select the value and click Set as common name (check mark). The value should now appear bold.
Если вы хотите получить сертификат для одного имени хоста, выберите другие значения по одному и нажмите кнопку Удалить значок). If you want a certificate for a single host name, select the other values one at a time and click Remove ( ).
Когда вы закончите работу на этой странице, нажмите кнопку Готово. When you’re finished on this page, click Finish.
Примечания. Notes:
Имя узла, выделенное полужирным шрифтом, будет использоваться для поля Subject сертификата, и его невозможно удалить. Сначала необходимо выбрать или добавить другое имя узла, а затем установить флажок Задать как общее имя. You can’t delete the bold host name value that will be used for the certificate’s Subject field. First, you need to select or add a different host name, and then click Set as common name (check mark).
Если нажать кнопку Назад, изменения, внесенные на этой странице, могут быть потеряны. The changes that you make on this page might be lost if you click the Back button.
Создать самозаверяющий сертификат Exchange с помощью командной консоли Exchange Use the Exchange Management Shell to create a new Exchange self-signed certificate
Чтобы создать самозаверяющий сертификат Exchange, используйте следующий синтаксис: To create a new Exchange self-signed certificate, use the following syntax:
В этом примере создается самозаверяющий сертификат на локальном сервере Exchange со следующими свойствами: This example creates a self-signed certificate on the local Exchange server with the following properties:
Тема: . Subject: . Например, если вы запустите команду на сервере с именем Mailbox01, значение Mailbox01 будет . For example, if you run the command on the server named Mailbox01, the value is Mailbox01 .
Тема альтернативных имен: , . Subject alternative names: , . Например, Mailbox01, Mailbox01.contoso.com . For example, Mailbox01, Mailbox01.contoso.com .
Удобное имя: Microsoft Exchange Friendly name: Microsoft Exchange
Службы: POP, IMAP, SMTP. Services: POP, IMAP, SMTP.
В этом примере создается самозаверяющий сертификат на локальном сервере Exchange со следующими свойствами: This example creates a creates a self-signed certificate on the local Exchange server with the following properties:
Тема: Exchange01, которая требует значения CN=Exchange01 . Subject: Exchange01, which requires the value CN=Exchange01 . Обратите внимание, что это значение автоматически включается в параметр DomainName (поле Subject Alternative Name). Note that this value is automatically included in the DomainName parameter (the Subject Alternative Name field).
Дополнительные альтернативные имена субъекта: Additional subject alternative names:
Службы: SMTP, IIS Services: SMTP, IIS
Удобное имя: сертификат Contoso Exchange Friendly name: Contoso Exchange Certificate
Закрытый ключ можно экспортировать. То есть вы можете экспортировать сертификат с сервера и импортировать его на другие серверы. The private key is exportable. This allows you to export the certificate from the server (and import it on other servers).
Примечания. Notes:
Единственная необходимая часть значения параметров SubjectName X.500 (поле Subject) сертификата CN= . The only required part of the X.500 SubjectName parameter value (the certificate’s Subject field) is CN= .
Некоторые значения параметра Services приводят к появлению предупреждений или подтверждений. Some Services parameter values generate warning or confirmation messages. Дополнительные сведения см. в справке Назначение сертификатов Exchange Server службам. For more information, see Assign certificates to Exchange Server services.
Дополнительные сведения см. в статье New-ExchangeCertificate. For more information, see New-ExchangeCertificate.
Как убедиться, что все получилось? How do you know this worked?
Чтобы убедиться, что вы успешно создали самозаверяющий сертификат Exchange, выполните любое из следующих действий: To verify that you have successfully created an Exchange self-signed certificate, perform either of the following steps:
В Центре администрирования Exchange выберите Серверы > Сертификаты, убедитесь, что выбран сервер, на котором вы создали самозаверяющий сертификат. Сертификат должен быть в списке сертификатов и иметь статус Действительный. In the EAC at Servers > Certificates, verify the server where you created the self-signed certificate is selected. The certificate should be in the list of certificates with the Status value Valid.
В командной консоли Exchange на сервере, где вы создали самозаверяющий сертификат, выполните следующую команду и проверьте свойства: In the Exchange Management Shell on the server where you created the self-signed certificate, run the following command and verify the properties: