@@ -38,9 +38,25 @@ CDialogPKCS12::CDialogPKCS12(SSLCertificates *Certificate, QString Filename, boo
3838 this ->ui ->pushButtonImportCert ->hide ();
3939 this ->ui ->pushButtonImportMain ->hide ();
4040 this ->ui ->pushButtonPushAll ->hide ();
41+ for (unsigned long long i=0 ; i<this ->cert ->p12Encrypt .size ();i++)
42+ {
43+ this ->ui ->comboBoxCertEncryption ->addItem (QString::fromStdString (this ->cert ->p12Encrypt [i].second ),QVariant (this ->cert ->p12Encrypt [i].first ));
44+ this ->ui ->comboBoxKeyEncryption ->addItem (QString::fromStdString (this ->cert ->p12Encrypt [i].second ),QVariant (this ->cert ->p12Encrypt [i].first ));
45+ }
46+ for (unsigned long long i=0 ; i<this ->cert ->p12KeyType .size ();i++)
47+ {
48+ this ->ui ->comboBoxKeyType ->addItem (QString::fromStdString (this ->cert ->p12KeyType [i].second ),QVariant (this ->cert ->p12KeyType [i].first ));
49+ }
4150 }
4251 else
4352 {
53+ this ->ui ->comboBoxCertEncryption ->hide ();
54+ this ->ui ->labelCertEncryption ->hide ();
55+ this ->ui ->comboBoxKeyEncryption ->hide ();
56+ this ->ui ->labelKeyEncryption ->hide ();
57+ this ->ui ->comboBoxKeyType ->hide ();
58+ this ->ui ->labelKeyType ->hide ();
59+
4460 this ->ui ->lineEditPassword ->hide ();
4561 this ->ui ->labelPassword ->hide ();
4662 this ->ui ->pushButtonLoadCert ->hide ();
@@ -179,7 +195,37 @@ void CDialogPKCS12::on_pushButtonSaveAs_clicked()
179195 QString pass=ui->lineEditPassword ->text ();
180196 ui->lineEditPassword ->setText (" " );
181197 ui->lineEditPassword ->setText (" " );
182- switch (this ->cert ->save_to_pkcs12 (file,name.toLocal8Bit ().data (),pass.toLocal8Bit ().data ()))
198+
199+ int keyType,certEncrypt,keyEncrypt = 0 ;
200+ if (ui->comboBoxKeyType ->currentData ().canConvert (QMetaType::Int))
201+ {
202+ keyType = ui->comboBoxKeyType ->currentData ().toInt ();
203+ }
204+ else
205+ {
206+ QMessageBox::warning (this ,tr (" Error in keytype" ),tr (" Invalid key type : " )+ui->comboBoxKeyType ->currentData ().toString ());
207+ return ;
208+ }
209+ if (ui->comboBoxCertEncryption ->currentData ().canConvert (QMetaType::Int))
210+ {
211+ certEncrypt = ui->comboBoxCertEncryption ->currentData ().toInt ();
212+ }
213+ else
214+ {
215+ QMessageBox::warning (this ,tr (" Error in keytype" ),tr (" Invalid key type : " )+ui->comboBoxCertEncryption ->currentData ().toString ());
216+ return ;
217+ }
218+ if (ui->comboBoxKeyEncryption ->currentData ().canConvert (QMetaType::Int))
219+ {
220+ keyEncrypt = ui->comboBoxKeyEncryption ->currentData ().toInt ();
221+ }
222+ else
223+ {
224+ QMessageBox::warning (this ,tr (" Error in keytype" ),tr (" Invalid key type : " )+ui->comboBoxKeyEncryption ->currentData ().toString ());
225+ return ;
226+ }
227+
228+ switch (this ->cert ->save_to_pkcs12 (file,name.toLocal8Bit ().data (),pass.toLocal8Bit ().data (),keyEncrypt,certEncrypt,0 ,0 ,keyType))
183229 {
184230 case 0 :
185231 QMessageBox::information (this ,tr (" Saved" ),tr (" File saved" ));
0 commit comments