mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-09 17:06:18 +00:00
Fix problem with certificate exception catching
This commit is contained in:
parent
7d0c79876c
commit
096d3b9165
@ -100,7 +100,7 @@ public class AdvancedX509TrustManager implements X509TrustManager {
|
||||
* @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],
|
||||
* String authType)
|
||||
*/
|
||||
public void checkServerTrusted(X509Certificate[] certificates, String authType) throws CertificateException {
|
||||
public void checkServerTrusted(X509Certificate[] certificates, String authType) {
|
||||
if (!isKnownServer(certificates[0])) {
|
||||
CertificateCombinedException result = new CertificateCombinedException(certificates[0]);
|
||||
try {
|
||||
|
@ -118,6 +118,22 @@ public class RemoteOperationResult<T extends Object>
|
||||
code == ResultCode.OK_REDIRECT_TO_NON_SECURE_CONNECTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RemoteOperationResult based on the result given by a previous one.
|
||||
* It does not copy the data.
|
||||
* @param prevRemoteOperation
|
||||
*/
|
||||
public RemoteOperationResult(RemoteOperationResult prevRemoteOperation) {
|
||||
mCode = prevRemoteOperation.mCode;
|
||||
mHttpCode = prevRemoteOperation.mHttpCode;
|
||||
mHttpPhrase = prevRemoteOperation.mHttpPhrase;
|
||||
mAuthenticate = prevRemoteOperation.mAuthenticate;
|
||||
mException = prevRemoteOperation.mException;
|
||||
mLastPermanentLocation = prevRemoteOperation.mLastPermanentLocation;
|
||||
mSuccess = prevRemoteOperation.mSuccess;
|
||||
mRedirectedLocation = prevRemoteOperation.mRedirectedLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public constructor from exception.
|
||||
*
|
||||
|
@ -31,6 +31,7 @@ import android.net.Uri;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.http.HttpConstants;
|
||||
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
|
||||
import com.owncloud.android.lib.common.network.CertificateCombinedException;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@ -41,6 +42,8 @@ import org.json.JSONObject;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
@ -88,8 +91,8 @@ public class GetRemoteStatusOperation extends RemoteOperation<OwnCloudVersion> {
|
||||
try {
|
||||
status = client.executeHttpMethod(getMethod);
|
||||
mLatestResult = new RemoteOperationResult(OK);
|
||||
} catch (SSLPeerUnverifiedException certEx) {
|
||||
mLatestResult = new RemoteOperationResult(certEx);
|
||||
} catch (SSLException sslE) {
|
||||
mLatestResult = new RemoteOperationResult(sslE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user