procedure TfrmGenerateCert.btnGenerateClick(Sender: TObject);
var
Cert : TElX509CertificateEx;
SigAlg, KeyAlg : TElAlgorithmIdentifier;
ind : integer;
begin
SigAlg := TElAlgorithmIdentifier.CreateByAlgorithm(GetSignatureAlgorithm);
KeyAlg := TElAlgorithmIdentifier.CreateByAlgorithm(GetPublicKeyAlgorithm);
if KeyAlg is TElECAlgorithmIdentifier then
TElECAlgorithmIdentifier(KeyAlg).Curve := GetCurve
else if KeyAlg is TElGOST3410AlgorithmIdentifier then
TElGOST3410AlgorithmIdentifier(KeyAlg).PublicKeyParamSet := GetGostParamset;
Cert := TElX509CertificateEx.Create(nil);
Cert.SubjectRDN.Count := 6;
For ind:=0 to 5 do Cert.SubjectRDN.Tags[ind] := SB_ASN1_PRINTABLESTRING;
Cert.SubjectRDN.OIDs[0] := SB_CERT_OID_COUNTRY;
Cert.SubjectRDN.Values[0] := GetCountryAbbr(cbCountry.Text);
Cert.SubjectRDN.OIDs[1] := SB_CERT_OID_STATE_OR_PROVINCE;
Cert.SubjectRDN.Values[1] := edtState.Text;
Cert.SubjectRDN.OIDs[2] := SB_CERT_OID_LOCALITY;
Cert.SubjectRDN.Values[2] := edtLocality.Text;
Cert.SubjectRDN.OIDs[3] := SB_CERT_OID_ORGANIZATION;
Cert.SubjectRDN.Values[3] := edtOrganization.Text;
Cert.SubjectRDN.OIDs[4] := SB_CERT_OID_ORGANIZATION_UNIT;
Cert.SubjectRDN.Values[4] := edtOrganizationUnit.Text;
Cert.SubjectRDN.OIDs[5] := SB_CERT_OID_COMMON_NAME;
Cert.SubjectRDN.Values[5] := edtCommonName.Text;
Cert.ValidFrom := dtpFrom.Date;
Cert.ValidTo := dtpTo.Date;
if rbSelfSigned.Checked then
begin
Cert.CAAvailable := False;
Cert.IssuerRDN.Count := 6;
For ind:=0 to 5 do Cert.IssuerRDN.Tags[ind] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.Tags[0] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.OIDs[0] := SB_CERT_OID_COUNTRY;
Cert.IssuerRDN.Values[0] := GetCountryAbbr(cbCountry.Text);
Cert.IssuerRDN.Tags[1] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.OIDs[1] := SB_CERT_OID_STATE_OR_PROVINCE;
Cert.IssuerRDN.Values[1] := edtState.Text;
Cert.IssuerRDN.Tags[2] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.OIDs[2] := SB_CERT_OID_LOCALITY;
Cert.IssuerRDN.Values[2] := edtLocality.Text;
Cert.IssuerRDN.Tags[3] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.OIDs[3] := SB_CERT_OID_ORGANIZATION;
Cert.IssuerRDN.Values[3] := edtOrganization.Text;
Cert.IssuerRDN.Tags[4] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.OIDs[4] := SB_CERT_OID_ORGANIZATION_UNIT;
Cert.IssuerRDN.Values[4] := edtOrganizationUnit.Text;
Cert.IssuerRDN.Tags[0] := SB_ASN1_PRINTABLESTRING;
Cert.IssuerRDN.OIDs[5] := SB_CERT_OID_COMMON_NAME;
Cert.IssuerRDN.Values[5] := edtCommonName.Text;
end;
Screen.Cursor := crHourGlass;
Generating := true;
btnBack.Enabled := false;
btnNext.Enabled := false;
btnCancel.Enabled := false;
btnGenerate.Enabled := false;
If rbSelfSigned.Checked then
Thread := TCertificateGenerationThread.Create(nil, Cert)
else
Thread := TCertificateGenerationThread.Create(CACert, Cert);
TCertificateGenerationThread(Thread).SignatureAlgorithm := SigAlg;
TCertificateGenerationThread(Thread).KeyAlgorithm := KeyAlg;
TCertificateGenerationThread(Thread).Bits := GetKeyLength;
Thread.OnTerminate := HandleThreadTerminate;
StartProgressbar;
Thread.Resume;
end;