Java 文件上传使用https错误?
我的密码是Java 文件上传使用https错误?,java,https,ioexception,Java,Https,Ioexception,我的密码是 Properties systemProps = System.getProperties(); systemProps.put( "javax.net.ssl.trustStore", System.getProperty("catalina.home")+fs+".keystore"); System.setProperties(systemProps); try { // Open a secure connection. URL
Properties systemProps = System.getProperties();
systemProps.put( "javax.net.ssl.trustStore",
System.getProperty("catalina.home")+fs+".keystore");
System.setProperties(systemProps);
try {
// Open a secure connection.
URL url = new URL( "https://192.168.6.45:8181/erp_adapter/UploadFile" );
String requestParams = "uid=sdfn&password=rsdftesan&active=y&type=F";
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
// Set up the connection properties
con.setRequestProperty( "Connection", "close" );
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setConnectTimeout( 30000 );
con.setReadTimeout( 30000 );
con.setRequestMethod( "POST" );
con.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" );
con.setRequestProperty( "Content-Length", Integer.toString(requestParams.length()) );
// Set up the user authentication portion of the handshake with the private
// key provided by NAIMES Tech Support.
// Based on an example posted by Torsten Curdt on his blog:
// http://vafer.org/blog/20061010073725 (as of Nov, 2009)
File pKeyFile = new File(System.getProperty("catalina.home")+fs+".keystore");
String pKeyPassword = "UB#20abba";
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
KeyStore keyStore = KeyStore.getInstance("PKCS12");
InputStream keyInput = new FileInputStream(pKeyFile);
//byte[] Password=pKeyPassword.getBytes();
keyStore.load(keyInput, pKeyPassword.toCharArray());
keyInput.close();
这里显示一个错误,如下所示:
java.io.IOException:DerInputStream.getLength:lengthTag=109,太大。
位于sun.security.util.DerInputStream.getLengthUnknown源
位于sun.security.util.DerValue.initUnknown Source
位于sun.security.util.DerValue.Unknown Source
位于com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoadUnknown源
位于java.security.KeyStore.loadUnknown Source
在com.gofrugal.raymedi.erp.util.aidaclient.mainAidapClient.java:58
有人能帮我解决问题吗?您试图加载的密钥库可能不是Sun PKCS12密钥库的实例。发出以下命令以查找密钥库的类型
keytool -list -keystore <keystore_location>
在这种情况下,密钥库是一个JKS密钥库,我猜你的也是,你会想这样做的
KeyStore.getInstance("JKS");
您尝试加载的密钥库可能不是Sun PKCS12密钥库的实例。发出以下命令以查找密钥库的类型
keytool -list -keystore <keystore_location>
在这种情况下,密钥库是一个JKS密钥库,我猜你的也是,你会想这样做的
KeyStore.getInstance("JKS");
您发布了两个互不相关的代码段。代码的任何部分都没有上传位。您能否更具体地说明错误的来源。从当前堆栈跟踪来看,它与https或文件上传无关,正如您在问题中所说。您发布了两个互不相关的代码段。代码的任何部分都没有上传位。您能否更具体地说明错误的来源。从当前堆栈跟踪来看,它与您在问题中所说的https或文件上载无关。这在使用jarsigner时也适用,确保不要将storetype指定为pkcs12。这在使用jarsigner时也适用,确保不要将storetype指定为pkcs12