mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
580 stars 86 forks source link

Authentication failed Malformed URL #320

Closed xianwenchen closed 10 months ago

xianwenchen commented 11 months ago

Hi!

I haven't been able to use davmail since about one week ago.

I am still prompt with a authenticator number. I confirm it on the authenticator. Then I'm asked "Are you trying to sign in to Microsoft Office". I clicked continue, then davmail notifies me the error "Authentication failed Malformed URL".

The davmail version is 6.0.1-trunk.

Here is the configuration:

davmail.ssl.keystoreType=
davmail.ssl.keystorePass=
davmail.proxyPassword=
davmail.oauth.tenantId=
davmail.oauth.clientId=d3590ed6-52b3-4102-aeff-aad2292ab01c
davmail.smtpPort=1025
davmail.enableKerberos=false
davmail.folderSizeLimit=0
davmail.forceActiveSyncUpdate=false
davmail.enableKeepalive=false
davmail.imapAutoExpunge=true
davmail.useSystemProxies=false
davmail.proxyUser=
davmail.caldavEditNotifications=false
davmail.ssl.nosecuresmtp=false
davmail.caldavPastDelay=90
davmail.ssl.keyPass=
log4j.logger.httpclient.wire=WARN
davmail.noProxyFor=
davmail.server=false
log4j.logger.org.apache.commons.httpclient=WARN
davmail.popMarkReadOnRetr=false
davmail.ssl.nosecureimap=false
davmail.disableTrayActivitySwitch=false
davmail.caldavAutoSchedule=false
davmail.enableProxy=false
davmail.proxyPort=
davmail.logFileSize=100MB
davmail.enableEws=true
davmail.mode=O365Interactive
davmail.smtpSaveInSent=true
davmail.bindAddress=
davmail.ssl.nosecurepop=false
davmail.ssl.pkcs11Library=
log4j.rootLogger=WARN
davmail.ssl.keystoreFile=
log4j.logger.davmail=WARN
davmail.clientSoTimeout=
davmail.ssl.clientKeystoreType=
davmail.ssl.pkcs11Config=
davmail.ssl.clientKeystorePass=
davmail.imapPort=1143
davmail.url=https://outlook.office365.com/EWS/Exchange.asmx
log4j.logger.org.apache.http.conn.ssl=WARN
davmail.sentKeepDelay=90
davmail.ssl.nosecureldap=false
davmail.imapAlwaysApproxMsgSize=false
davmail.ssl.nosecurecaldav=false
davmail.popPort=1110
davmail.defaultDomain=
davmail.showStartupBanner=true
davmail.proxyHost=
davmail.ldapPort=1389
davmail.server.certificate.hash=
log4j.logger.org.apache.http.wire=WARN
davmail.disableGuiNotifications=false
davmail.imapIdleDelay=
davmail.allowRemote=true
davmail.disableUpdateCheck=true
log4j.logger.org.apache.http=WARN
davmail.caldavPort=1080
davmail.enableKeepAlive=false
davmail.ssl.clientKeystoreFile=
davmail.logFilePath=/foo/bar/log
davmail.keepDelay=30
davmail.oauth.redirectUri=urn:ietf:wg:oauth:2.0:oob
davmail.caldavAlarmSound=
esabol commented 11 months ago

@xianwenchen wrote:

The davmail version is 6.0.1-trunk.

Well, 6.2.0 is the latest release. Try upgrading to that.

But I imagine you need to talk to your email administrator. They've probably changed something with how your email service is configured.

mguessan commented 11 months ago

Just check the O365Interactive authenticator is still working, Microsoft didn't break it (yet).

Can you please provide more details from the errors in davmail.log (or forward the whole file to mguessan@free.fr)?

An alternative it to switch to O365Manual and use your native browser to authenticate

xianwenchen commented 11 months ago

Thanks. The log was simple, using the interactive mode:

2023-12-22 13:05:31,360 WARN  [AWT-EventQueue-0] davmail.exchange.auth.O365InteractiveAuthenticatorFrame  - Unable to register protocol handler
2023-12-22 13:06:13,544 ERROR [JavaFX Application Thread] davmail.exchange.auth.O365InteractiveAuthenticatorFrame  - java.lang.Throwable: Malformed URL Malformed URL
2023-12-22 13:06:14,357 ERROR [ImapConnection-58902] davmail.exchange.auth.O365InteractiveAuthenticator  - Authentication failed Malformed URL
2023-12-22 13:06:14,357 ERROR [ImapConnection-58902] davmail  - Authentication failed Malformed URL
davmail.exception.DavMailException: Authentication failed Malformed URL
    at davmail.exchange.auth.O365InteractiveAuthenticator.authenticate(O365InteractiveAuthenticator.java:181)
    at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:182)
    at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:97)
    at davmail.imap.ImapConnection.run(ImapConnection.java:128)
mguessan commented 11 months ago

The key is there: Unable to register protocol handler

That's the interceptor for the urn: url

=> you have a recent java version, you need to allow access to internal java API with: --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED

The winrun4j wrappers already include this, if you launch DavMail manually you need to include the option above in the command line

xianwenchen commented 11 months ago

Thank you. I run it on Debian.

The content of /usr/bin/davmail is

#!/bin/sh
export SWT_GTK3=0
exec /usr/bin/java \
    -jar /usr/share/davmail/davmail.jar "$@"

I tried running

davmail --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED ~/data/archive/davmail/config/davmail.com.office.outlook.spoofed_client_id.properties

However, I still got the same error.

esabol commented 11 months ago

What version of Java are you using? And do you have OpenJDK or Oracle JDK? Maybe there's a difference....

xianwenchen commented 11 months ago

I'm using OpenJDK:

openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-1deb12u1, mixed mode, sharing)
esabol commented 11 months ago

And java -version?

This is probably silly, but I would try putting the --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED arguments before the -jar /usr/share/davmail/davmail.jar arguments in your java command.

xianwenchen commented 10 months ago

Thank you!

Your were right that I shall put --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED arguments before -jar /usr/share/davmail/davmail.jar!

esabol commented 10 months ago

So that worked? Wonderful!