问题标签 [certenroll]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
172 浏览

fiddler - Fiddler 生成的证书具有无效的数字签名

提琴手:.NET 4.6.1 的 v5.0.20182.28034

证书生成器:尝试了 CertEnroll 和 MakeCert

机器:Windows 10

浏览器:铬

我也尝试安装新的提琴手,但没有成功。我什至安装并重新安装了 Fiddler Root Cert。

在此处输入图像描述

0 投票
3 回答
286 浏览

javascript - 如何使用 IE11 和 certenroll 向 PKCS10 证书请求添加 challengePassword?

我在 Internet Explorer 11 中使用 Certenroll 创建 PKCS10 证书签名请求以发送到证书颁发机构。

我需要将 challengePassword 属性(OID 1.2.840.113549.1.9.7)添加到生成的 CSR 中,并且我正在努力确定执行此操作的确切代码。

我试图创建一个 X509Enrollment.CX509Extension 并将其添加到 CSR,但尝试将值分配给扩展时代码失败:

出现以下错误:

唉,我没有被告知三个参数中的哪一个是无效的,或者是什么使参数不正确。

代码如下:

有人可以确认我在 objX509ExtensionChallenge.Initialize() 调用中做错了什么,这会导致失败吗?

编辑1:

如下更改代码可避免无效参数错误,但生成的 CSR 中没有 1.2.840.113549.1.9.7 OID:

生成的证书请求如下:

0 投票
1 回答
366 浏览

c# - 尝试使用从 CurrentUser Store 检索到的证书的私钥时出错

我正在尝试使用我的证书代理证书签署 CSR。但是,当我从 currentUser 的商店获取证书并尝试使用密钥对其进行签名时,我收到此错误“CertEnroll::CSignerCertificate::Initialize: 找不到对象或属性。0x80092004 (-2146885628 CRYPT_E_NOT_FOUND)”但是如果我得到它从 LocalMachine Store 我没有这个问题,它可以工作。我无法使用本地计算机存储证书,因为证书代理证书的私钥不可导出。

这是我从 cert sotre 获取证书的代码:

但是当我调用 CERTENROLLLib 初始化程序 (Initialize(bool MachineContext, X509PrivateKeyVerify VerifyType, EncodingType Encoding, string strCertificate)) 时,我得到了上面提到的异常。查看调试器,当它来自 LocalMachine 时,变量看起来与来自 LocalMachine 时相同来自当前用户。

0 投票
1 回答
439 浏览

c# - 无法代表用户请求智能卡证书

我正在创建一个服务来获取SmartCard唯一域中的用户智能卡(所以我无法通过用户的身份验证,因为他们没有注册智能卡,所以我使用其他身份验证方法来验证用户)然后用户向我发送他的 CSR但是当我尝试代表用户创建证书时,出现以下错误:

“CertEnroll::CX509Enrollment::Enroll:这种类型的证书只能颁发给用户。:未为应用程序 0x8004e00c (-2147164148 CONTEXT_E_ROLENOTFOUND) 配置指定的角色”

我创建了一个有权访问的服务帐户,Enrollment Agent Certificate并为该帐户创建了一个证书。我还创建了一个智能卡模板,该模板需要注册代理证书签名才能代表用户请求证书,并授予该服务帐户对该模板的完全访问权限。该应用程序在使用该服务帐户作为身份的 IIS 应用程序池中运行,我使用此代码请求证书(它使用CERTENROLLLib):

我还将 IIS 帐户切换为在我的用户下运行,但仍然出现错误。我是否必须以某种方式向 CA 进行身份验证,或者它是否使用我的 IIS 身份来请求请求(我确实通过检查 this 的输出来验证它是否在上下文中运行System.Security.Principal.WindowsIdentity.GetCurrent().Name)?

0 投票
1 回答
118 浏览

c# - (WIN32: 1400 ERROR_INVALID_WINDOW_HANDLE) 使用智能卡签署 CSR 时

我正在尝试使用 CertEnroll::CX509CertificateRequestPkcs10 库从智能卡生成 CSR。如果我只是在开始时运行它,它就可以正常工作。但是,如果我事先运行 ADAL 登录流程,则会收到以下错误。

CertEnroll::CX509CertificateRequestPkcs10::Encode:无效的窗口句柄。0x80070578 (WIN32: 1400 ERROR_INVALID_WINDOW_HANDLE)

我查看了错误,似乎是当您调用不再存在的窗口时引起的。由于我无法控制 CertEnroll::CX509CertificateRequestPkcs10::Encode 调用的窗口,有没有办法清除指针或避免此错误?

供参考这里是我的注册码

这是我的验证码

0 投票
1 回答
174 浏览

javascript - 尝试使用 JS 在浏览器上安装证书时出错

在我的代码中,我有一个调用 JS 文件的按钮,该文件又调用一个 PHP 文件,该文件具有我需要生成证书的 API 端点,并将我在下面的证书变量中使用的响应发回。

我正在使用 openssl 命令自己生成 CSR。

我在浏览器上安装证书的代码如下(证书是我将证书作为从 Entrust API 获得的响应传递的地方)-

我正在使用此页面上的代码 - https://blogs.msdn.microsoft.com/alejacma/2009/01/28/how-to-create-a-certificate-request-with-certenroll-javascript/(正下方的第二个灰色块- 以下 Javascript 示例显示了如何安装来自 CA 的响应

我遇到的错误是(来自 catch 块)-

我不确定无法找到对象或属性是什么意思,因为它不太冗长。

PS:如果我将来自 API 的响应保存为 .crt 文件并打开它(只需双击),证书值和证书链看起来都是正确的。

0 投票
1 回答
155 浏览

c# - Certenroll on Azure - Generating self signed certificates

I have built a creation self-signing certificates using Certenroll (CERTENROLLLib). All works locally but as soon as I deploy it to Azure I get either:

Server API error: Message: CertEnroll::CX509Enrollment::_CreateRequest: Access is denied. 0x80070005 (WIN32: 5 ERROR_ACCESS_DENIED), StackTrace: at CERTENROLLLib.IX509Enrollment2.CreateRequest(EncodingType Encoding)
at Foo.Api.Core.Providers.CertificateProvider.GenerateBase64EncodedPfx(String subjectName, Int32 certificateValidityInYears, String password) at Foo.Api.Core.Services.CertificateService.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Foo.ServerApi.Services.DocumentSigningService.d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Foo.ServerApi.Services.DocumentSigningService.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Foo.ServerApi.Controllers.DocumentController.<>c__DisplayClass10_1.<b__5>d.MoveNext()

if using:

or

Server API error: Message: CertEnroll::CX509CertificateRequestCertificate::InitializeFromPrivateKey: The parameter is incorrect. 0x80070057 (WIN32: 87 ERROR_INVALID_PARAMETER), StackTrace: at CERTENROLLLib.IX509CertificateRequestCertificate2.InitializeFromPrivateKey(X509CertificateEnrollmentContext Context, IX509PrivateKey pPrivateKey, String strTemplateName) at Foo.Api.Core.Providers.CertificateProvider.GenerateBase64EncodedPfx(String subjectName, Int32 certificateValidityInYears, String password) at Foo.Api.Core.Services.CertificateService.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Foo.ServerApi.Services.DocumentSigningService.d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Foo.ServerApi.Services.DocumentSigningService.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Foo.ServerApi.Controllers.DocumentController.<>c__DisplayClass10_1.<b__5>d.MoveNext()

if using:

Is there any way how to overcome this issue with Certenroll on Azure?

Edit: final error that lead me to the correct path.

Server API error: Message: CertEnroll::CX509PrivateKey::Create: The system cannot find the file specified. 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND), StackTrace: at CERTENROLLLib.IX509PrivateKey2.Create() at Foo.Api.Core.Providers.CertificateProvider.GenerateBase64EncodedPfx(String subjectName, Int32 certificateValidityInYears, String password) at Foo.Api.Core.Services.CertificateService.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Foo.ServerApi.Services.DocumentSigningService.d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Foo.ServerApi.Services.DocumentSigningService.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Foo.ServerApi.Controllers.DocumentController.<>c__DisplayClass10_1.<b__5>d.MoveNext()

0 投票
0 回答
123 浏览

c# - 没有用户登录时如何注册证书?

我使用此链接注册新证书。

当 Windows 被锁定或登录时,一切正常并创建请求并正确安装。

将代码作为 Windows 服务运行,因此当我重新启动机器时,服务正在启动时无法创建请求并得到以下行的错误:

错误是:

System.IO.FileNotFoundException: CertEnroll::CX509PrivateKey::Create: 系统找不到指定的文件。0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND) 在 CERTENROLLLib.IX509PrivateKey2.Create()

知道如何解决这个问题吗?谢谢

0 投票
1 回答
216 浏览

c# - 从 makecert.exe 升级到 CertEnroll - 证书信任问题

到目前为止,我有一个应用程序使用 makecert.exe 生成自我证书。但是,由于 makecert 无法添加 SubjectAltName 字段,我需要将代码迁移到 certenroll.dll

这是原始的 makecert 代码:

这是 certenroll.dll 代码:

除了 Crypt32 的帮助之外,我现在遇到了 signerCertificate.Initialize 行的问题。我似乎无法让它使用我的自我证书。根证书。我假设我正在尝试以错误的格式提供它,因为我收到以下错误:

证书不具有引用私钥的属性。0x8009200a (CRYPT_E_UNEXPECTED_MSG_TYPE)

0 投票
1 回答
89 浏览

c# - 使用 certenroll 创建证书时的 CRYPT_E_UNEXPECTED_MSG_TYPE

我正在尝试使用 certenroll 创建一个自签名证书,但 CSignerCertificate::Initialize 似乎有问题,因为它会引发错误 0x8009200a CRYPT_E_UNEXPECTED_MSG_TYPE。

'MyCustomRoot' 是我在当前用户-> 个人-> 证书存储中的自签名根证书的名称。

我哪里错了?