void generate_cert() { char type; certificate cert; INIT(cert); char pwd[100]; char name[100]; printf("是否生成一个ca(y/n):"); scanf("%c",&type); if(type == 'y') { generate_ca_cert(&cert); strcpy(pwd,"/home/ljh/ljh-wave-1609.2/cert/ca_cert/ca.cert"); cert_2_file(&cert,pwd); certificate_printf(&cert); } else { printf("输入证书名字:"); scanf("%s",name); generate_no_ca_cert(&cert,name); strcpy(pwd,"/home/ljh/ljh-wave-1609.2/cert/issued_cert/"); strcat(pwd,name); strcat(pwd,".cert"); cert_2_file(&cert,pwd); certificate_printf(&cert); } }
static void cmp_db_2_file(struct cmp_db* cmdb,const char* name){ int fd; if (( fd = open(name,O_WRONLY|O_CREAT|O_TRUNC) ) <0 ){ wave_printf(MSG_ERROR,"打开文件 %s 失败",name); return ; } if ( crl_req_time_list_2_file(cmdb,fd) <0) goto fail; if ( crl_cert_request_2_file(cmdb,fd) < 0) goto fail; if( lsis_array_2_file(cmdb,fd) < 0) goto fail; if( others_2_file(cmdb,fd) < 0) goto fail; if( cert_2_file(cmdb,fd) < 0) goto fail; close(fd); fail: close(fd); }