Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Java 7 against https://outlook.office365.com/EWS/Exchange.asmx TLSv1.2 #754

Open
dukeatfuture opened this issue Mar 29, 2022 · 0 comments
Open

Comments

@dukeatfuture
Copy link

Hello,
Is there a way to force TLSv1.2 with Java 7?

My code is simply connect and read some calendar items. The code has always work with on-premise Microsoft Exchange Server 2010. Now I try to connect to outlook.office365.com and I get "Conenction reset" error. If I use jdk-13.0.1 the code run fine.

The environment that I'm in forced me to stick to jdk1.7.0_55. In my search for answers Java 7 by default is set to TLSv1 and it is proven by the trace. TLSv1.2 is the default in Java 8 onward and it looks like outlook.office365.com require TLSv1.2.

Error:

`
Microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. Connection reset
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158)
at microsoft.exchange.webservices.data.core.ExchangeService.syncFolderItems(ExchangeService.java:2376)
...
main, WRITE: TLSv1 Handshake, length = 179
main, handling exception: java.net.SocketException: Connection reset
main, SEND TLSv1 ALERT: fatal, description = unexpected_message
main, WRITE: TLSv1 Alert, length = 2
main, Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error
main, called closeSocket()

`

Connection :
` final ExchangeCredentials credentials = new WebCredentials(user, password, domain);
if (this.isExchangeOnline) {
service = new ExchangeService(this.exchangeVersion365);
service.setUrl(new URI(this.ewsUrl365));
} else {
service = new ExchangeService(this.exchangeVersion);
service.setUrl(new URI(this.ewsUrl));
}
service.setCredentials(credentials);
service.setTraceEnabled(this.traceEws);
service.setTraceListener(traceListener);

        final ImpersonatedUserId impersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress,
                impersonatedUserSMTPAddress);

        service.setImpersonatedUserId(impersonatedUserId);

`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant