我需要通过命令行申请证书我已经调查过了证书请求是可以申请证书的工具。
我习惯通过选择其中一个可用模板来使用 GUI 来请求证书,但我需要通过命令行执行相同的操作。
关于如何实现这一点有什么想法吗?
答案1
如果您想要显示友好的 Active Directory 证书服务 CA 提供的证书模板列表(在命令行中),请使用certutil -CATemplates
。
C:\Windows\system32>certutil -CATemplates
DirectoryEmailReplication: Directory Email Replication -- Auto-Enroll: Access is denied.
DomainControllerAuthentication: Domain Controller Authentication -- Auto-Enroll: Access is denied.
KerberosAuthentication: Kerberos Authentication -- Auto-Enroll: Access is denied.
EFSRecovery: EFS Recovery Agent -- Auto-Enroll: Access is denied.
EFS: Basic EFS -- Auto-Enroll: Access is denied.
DomainController: Domain Controller -- Auto-Enroll: Access is denied.
WebServer: Web Server -- Auto-Enroll: Access is denied.
Machine: Computer -- Auto-Enroll: Access is denied.
User: User -- Auto-Enroll: Access is denied.
SubCA: Subordinate Certification Authority -- Auto-Enroll: Access is denied.
Administrator: Administrator -- Auto-Enroll: Access is denied.
CertUtil: -CATemplates command completed successfully.
另外,它还会告诉您当前是否有权注册每个特定模板。
要注册其中一个证书模板,请使用:
certreq -enroll -q WebServer
该-q
参数抑制所有交互式对话框,使其成为纯粹的命令行体验。
答案2
使用以下命令列出模板及其详细信息:
certutil.exe -Template
参考:https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/certutil