Источник
Creating a self-signed Certificate Authority (CA)
This creates a self-signed (-r) certificate, with an exportable private key (-pe). It's named "My CA", and should be put in the CA store for the current user. We're using the sha1 algorithm. The key is meant for signing (-sky).
The private key should be stored in the MyCA.pvk file, and the certificate in the MyCA.cer file.
то есть создали "доверенный" сертификат, с помощью которого потом создадим "рабочий" сертификат и уже им будем подписывать код
Importing the CA Certificate
Because there's no point in having a CA certificate if you don't trust it, you'll need to import it into the Windows certificate store. You can use the Certificates MMC snapin, but from the command line:
Creating a code-signing (SPC) Certificate
We'll also want to convert the certificate and key into a PFX file:
You can now use this certificate for signing code:
If you import the PFX file into the certificate store (you can use PVKIMPRT or the MMC snapin), you can sign code as follows:
Другой компьютер. Надо там сначала один раз выполнить:
Creating a self-signed Certificate Authority (CA)
makecert -r -pe -n "CN=My CA" -ss CA -sr LocalMachine(watch for line-breaks)
-a sha1 -sky signature -sv MyCA.pvk MyCA.cer
This creates a self-signed (-r) certificate, with an exportable private key (-pe). It's named "My CA", and should be put in the CA store for the current user. We're using the sha1 algorithm. The key is meant for signing (-sky).
The private key should be stored in the MyCA.pvk file, and the certificate in the MyCA.cer file.
то есть создали "доверенный" сертификат, с помощью которого потом создадим "рабочий" сертификат и уже им будем подписывать код
Importing the CA Certificate
Because there's no point in having a CA certificate if you don't trust it, you'll need to import it into the Windows certificate store. You can use the Certificates MMC snapin, but from the command line:
certutil -user -addstore Root MyCA.cerтак как созданный "доверенный" сертификат не настоящий (самоподписанный) - его ручками кладем куда надо
Creating a code-signing (SPC) Certificate
makecert -pe -n "CN=My SPC" -a sha1 -sky signaturePretty much the same as above, but we're providing an issuer key and certificate (the -ic and -iv switches).
-ic MyCA.cer -iv MyCA.pvk
-sv MySPC.pvk MySPC.cer
We'll also want to convert the certificate and key into a PFX file:
pvk2pfx -pvk MySPC.pvk -spc MySPC.cer -pfx MySPC.pfxIf you want to protect the PFX file, add the -po switch, otherwise PVK2PFX creates a PFX file with no passphrase.
You can now use this certificate for signing code:
signtool sign /v /f MySPC.pfx MyExecutable.exeэто последний шаг - приложение подписано! команда ниже - если хотим подписывать без файла pfx, а брать из хранилища сертификатов
If you import the PFX file into the certificate store (you can use PVKIMPRT or the MMC snapin), you can sign code as follows:
signtool sign /v /n "Me" /s SPC /d http://www.me.meНо это будет работать только на вашем компьютере, который знает о вашем самоподписанном доверенном источнике
/t http://timestamp.url MyExecutable.exe
Другой компьютер. Надо там сначала один раз выполнить:
certutil -user -addstore Root MyCA.cerПодписанные тобой программы будут показывать Publisher (без команды выше - нет). Также с другого компьютера можно и подписывать:
signtool sign /v /f MySPC.pfx MyExecutable.exeПодписывание сразу из Visual Studio через добавление в Post-build event command line
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\signtool.exe" sign /f [CERTIFICATE PATH] /p [PASSWORD] /t http://tsa.starfieldtech.com "$(TargetPath)"
3 комментария:
Очень интересный метод, ещё бы более подробно его описать по пунктам и со скриншотами. :)
deoВсё понятно кроме одного.
Полученный таким путём сертификат будет работать на других машинах?
Или же UAC будет ругаться мол сертификата нет... и сертификат некорректный?
Аноним, по слогам читай - всё написано.
Автору: самоподписный можно сделать проще, - не катит.
Отправить комментарий