0
  1. 我的证书是在生产帐户上创建的,但不是在沙盒帐户上创建的。
  2. 在 cert 上创建但上传的 pdf 证书无法从中下载。
  3. 我的问题是我无法下载 pdf(因为我认为它没有成功上传),请使用我的 SandBox 帐户进行测试。

下面详细介绍,我正在使用生产帐户令牌并在 cert 上创建证书,但上传的 pdf 无法下载。

@RequestMapping(method = RequestMethod.POST, value="/certificateFormData")
    public String certificateFormData(@RequestParam("file") MultipartFile inputFile,Model model,HttpServletRequest request) {
        System.out.println("**********");
        String pattern = "yyyy-MM-dd";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        String date = simpleDateFormat.format(new Date());
        Customer customer= (Customer)request.getSession().getAttribute("customer");

        try {
            if (!inputFile.isEmpty()) {

                System.out.println(inputFile.getName());


                    String exemptReason =   request.getParameter("exempt_reason");
                    String exposureZone =   request.getParameter("exposure_zones");
                    String exemptsCategory =request.getParameter("tax_exempt_category");
                    /*String taxNumber= request.getParameter("tax_number");
                    String verificationNumber = request.getParameter("verification_number");
                    */
                    System.out.println("getData================================>");
                    System.out.println("exempt reaosn"+exemptReason);
                    System.out.println(exposureZone);
                    System.out.println(exemptsCategory);

                    String  base64=Base64.getUrlEncoder().encodeToString(inputFile.getBytes());
                    StringBuilder query = new StringBuilder();
                    query.append("signed_date="+date);
                    query.append("&expiration_date="+"9999-12-31");
                    /*query.append("&valid="+true);
                    query.append("&verified="+true);*/
                    query.append("&never_renew="+true);
                    /*query.append("&renewable="+true);*/
                    query.append("&unused_multi_cert="+false);
                    query.append("&exmpt_percent="+0);/*
                    query.append("&verification_number="+verificationNumber);
                    query.append("&tax_number="+taxNumber);*/


                    query.append("&unused_multi_cert="+false);

                    for(TaxExemptReason reason: taxExemptReasons) {
                        if(reason.getId().equals(exemptReason)){
                            JSONObject obj = new JSONObject();
                            obj.put("id", exemptReason);
                            obj.put("name", reason.getName());
                            obj.put("tag", reason.getTag());
                            query.append("&expected_tax_code=" + obj.toString());
                        }   

                    }

                    for (ExposureZone zone :exposureZones) {
                        if (zone.getId().equals(exposureZone)) {
                            JSONObject obj = new JSONObject();
                            obj.put("id", exposureZone);
                            obj.put("name", zone.getName());
                            obj.put("tag", zone.getTag());
                            query.append("&exposureZone=" + obj.toString());
                        }
                    }
                    query.append("&status={\"name\":\"PENDING\"}");
                    query.append("&pdf=" + base64);


                    String response = certCaptureService.createCertificate(query,properties);
                    System.out.println("cert certificate response"+response);

                    JSONObject certCertificateJson= new  JSONObject(response);

                    if(response.contains("id"))
                    {

                        Certificate certificate= new Certificate();
                        certificate.setBigcommerceCustomerId(customer.getBigcommerceCustomerId());
                        certificate.setCertificateId(certCertificateJson.get("id")+"");
                        certificate.setCertCustomerId(customer.getCertCustomerId());
                        certificate.setCertCustomerNumber(customer.getCertCustomerNumber());
                        certificate.setClientId(customer.getClientId());
                        certificate.setExemptionCategory(exemptsCategory);
                        certificate.setCreatedate(new Timestamp(System.currentTimeMillis()));
                        certificate.setUpdateDate(new Timestamp(System.currentTimeMillis()));
                        certificate.setExempt_reason(exemptReason);
                        certificate.setExposure_zones(exposureZone);
                        certificate.setTaxDetails("");
                        customerDaoService.saveCertificate(certificate);

                        try {
                            String certificateQuery="certificates=[{\"id\":"+certCertificateJson.get("id")+"}]";
                            String certificateQueryResponse= certCaptureService.createCustomerwithCertificate(customer.getCertCustomerId(),
                                    certificateQuery, properties);
                            System.out.println("cert certificate customer response"+certificateQueryResponse);
                            if(certificateQueryResponse.contains("success")) 
                                model.addAttribute("response","Succcessfully create a certificate");
                            else
                                model.addAttribute("response","No Certificate Created.");
                        }catch (Exception e) {
                            model.addAttribute("response","No Certificate Created.");
                        }
                    }
                    else {
                        model.addAttribute("response","No Certificate Created.");
                    }

            }
        }catch (Exception e) {
            e.printStackTrace();
        }   
        return "redirect:/customer/"+customer.getBigcommerceCustomerId();
    }
4

1 回答 1

0

不确定这是否会对您的问题有所帮助,但起初我遇到了很多证书问题。安装三个证书(通配符、中间证书、根证书)时,将它们安装在 $JAVA_HOME/jre/lib/security 中。如果您将它们安装在您的 JAVA 主 JRE 中,它们应该由您的 IDE 拾取(前提是您使用的是该 JAVA 安装)。

于 2019-10-01T18:24:05.447 回答