Skip to content

Sign certificate failed because child_process.spawn get wrong result #26

Description

@wherewhere

certutil should return:

================ Certificate 0 ================
================ Begin Nesting Level 1 ================
Element 0:
Serial Number: 69cb5854cd86319c481d974e15339221
Issuer: CN=where
 NotBefore: 2021/10/10 21:16
 NotAfter: 2031/10/10 21:26
Subject: CN=where
Signature matches Public Key
Root Certificate: Subject matches Issuer
Cert Hash(sha1): 0cdf4a03e9be9dd789894bb3c7ad3dedecd9ab25
----------------  End Nesting Level 1  ----------------
  Provider = Microsoft Software Key Storage Provider
Private key is NOT plain text exportable
Encryption test passed
CertUtil: -dump command completed successfully.

But it return:

================ ֤�� 0 ================
================ ��ʼǶ�׵ȼ� 1 ================
Ԫ�� 0:
���к�: 69cb5854cd86319c481d974e15339221
�䷢��: CN=where
 NotBefore: 2021/10/10 21:16
 NotAfter: 2031/10/10 21:26
ʹ����: CN=where
ǩ���빫Կƥ��
��֤��: ʹ������䷢��ƥ��
֤���ϣ(sha1): 0cdf4a03e9be9dd789894bb3c7ad3dedecd9ab25
----------------  ����Ƕ�׵ȼ� 1  ----------------
  �ṩ���� = Microsoft Software Key Storage Provider
�޷��Դ��ı���ʽ����˽Կ
ͨ���˼��ܲ���
CertUtil: -dump ����ɹ���ɡ�

Which cause error: Unable to find publisher in Cert.

export const getCertPublisher = async (cert: string, cert_pass: string) => {
const args = [];
args.push('-p', cert_pass);
args.push('-dump', cert);
const certDump = await run('certutil', args);
const subjectRegex = /Subject:\s*(.*)/;
const match = certDump.match(subjectRegex);
const publisher = match ? match[1].trim() : null;
if(!publisher) {
log.error('Unable to find publisher in Cert');
}
return publisher;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions