将系统部署在was上,在调用微信接口生成media_id时报错,错误信息:
[20-4-17 16:30:32:052 CST] 000000e4 SystemErr R Caused by: com.ibm.jsse2.util.h: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:
java.security.cert.CertPathValidatorException: The certificate issued by CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US is not trusted; internal cause is:
java.security.cert.CertPathValidatorException: Certificate chaining error
[20-4-17 16:30:32:053 CST] 000000e4 SystemErr R at com.ibm.jsse2.util.f.a(f.java:109)
大佬们,求助啊!
运行到这 System.out.println("head=");之后没输出
public static String v_upload(File file, String url, String fileName,String introduction,String title) throws Exception {
System.out.println("v_upload--file="+file);
System.out.println("v_upload--url="+url);
System.out.println("v_upload--fileName="+fileName);
System.out.println("v_upload--introduction="+introduction);
System.out.println("v_upload--title="+title);
URL urlObj = new URL(url);
System.out.println("11111111111111");
HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
System.out.println("2222222222222");
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Connection", "Keep-alive");
con.setRequestProperty("Charset", "utf-8");
// 设置边界
String BOUNDARY = "----------" + System.currentTimeMillis();
con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY);
// 输出头
StringBuilder sb = new StringBuilder();
sb.append("--"); // 必须多两道线这里说明下,这两个横杠是http协议要求的,用来分隔提交的参数用的,不懂的可以看看http 协议头
sb.append(BOUNDARY);
sb.append("\r\n");
sb.append("Content-Disposition: form-data;name=\"type\" \r\n\r\n");//这里是参数名,参数名和值之间要用两次
sb.append("video/mp4\r\n"); //参数的值
sb.append("--"); // 必须多两道线
sb.append(BOUNDARY);
sb.append("\r\n");
sb.append("Content-Disposition: form-data; name=\"description\";\r\n\r\n");
sb.append(String.format("{\"title\":\"%s\", \"introduction\":\"%s\"}",title,introduction));
sb.append("--");
sb.append(BOUNDARY);
sb.append("\r\n");
sb.append("Content-Disposition:form-data;name=\"media\";filename=\"" + fileName + "\"\r\n");
sb.append("Content-Type:application/octet-stream\r\n\r\n");
System.out.println("v_upload--sb="+sb);
byte[] head = sb.toString().getBytes("utf-8");
System.out.println("head=");
OutputStream outStrm = con.getOutputStream();
System.out.println("con.getOutputStream()---"+outStrm);
OutputStream out = new DataOutputStream(outStrm);
System.out.println("aaaaa");
out.write(head);
// 输出体 =
System.out.println("333333333333333");
System.out.println(file.getAbsolutePath());
System.out.println("444444444");
DataInputStream in = new DataInputStream(new FileInputStream(file));
System.out.println("5555555555555");
int bytes = 0;
byte[] bufferOut = new byte[1024*10];
while ((bytes = in.read(bufferOut)) != -1) {
out.write(bufferOut, 0, bytes);
}
in.close();
// 输出尾巴
byte[] foot = ("\r\n--" + BOUNDARY + "--\r\n").getBytes();
out.write(foot);
out.flush();
out.close();
System.out.println("sb======="+sb);
System.out.println(out);
// 读取微信服务器返回的数据
StringBuffer buffer = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
reader.close();
return buffer.toString();
}