wakatime / jetbrains-wakatime

IntelliJ IDEA, PyCharm, RubyMine, PhpStorm, AppCode, AndroidStudio, Goland, Rider, & WebStorm plugin for quantifying your coding.
https://wakatime.com/intellij-idea
BSD 3-Clause "New" or "Revised" License
1.13k stars 167 forks source link

Authorised app no longer working SSL exception (handshake_failure) #138

Closed dosier closed 2 years ago

dosier commented 4 years ago

I use the WakaTme API to export my coding activity to an external format. Now this used to work fine the last time I did it (which was in January), but when I try to run it now, I get an SSL exception:

Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153) at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:143) at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:79) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:996) at com.stan.waka.WakaTime.run(WakaTime.kt:81) at com.stan.waka.WakaTime.main(WakaTime.kt:107)

I send an email to the WakaTime support team stating my issue, the reply said I should create an issue here so here it is.

private const val SCOPE = "read_logged_time"
private const val TOKEN_SERVER_URL = "https://wakatime.com/oauth/token"
private const val AUTHORIZATION_SERVER_URL = "https://wakatime.com/oauth/authorize"
private const val BASE_URL = "https://wakatime.com/api/v1/"

@JvmStatic
fun main(args: Array<String>){
    val credential = authorize()
    val requestFactory = HTTP_TRANSPORT.createRequestFactory(object : HttpRequestInitializer {
        @Throws(IOException::class)
        override fun initialize(request: HttpRequest) {
            credential.initialize(request)
            request.parser = JsonObjectParser(JSON_FACTORY)
        }
    })
    run(requestFactory)
}
fun run(requestFactory: HttpRequestFactory) {
    val baseUrl = BASE_URL + "users/current/projects/GrinderScapeSource/commits"
    val url = WakaTimeUrl(baseUrl)
    val request = requestFactory.buildGetRequest(url)

    val feeds = ArrayList<WakaCommitsFeed>()
    var feed = request.execute()//problematic part
                      .parseAs(WakaCommitsFeed::class.java)

    feeds.add(feed)

    while (feed.nextPage != null){
        feed = requestFactory
            .buildGetRequest(WakaTimeUrl(baseUrl+"?page=${feed.nextPage}"))
            .execute().parseAs(WakaCommitsFeed::class.java)
        feeds.add(feed)
        if(feed.page == 6)
            break
    }

    Report("2020-01-11", "2020-03-09", *feeds.toTypedArray())
}
gandarez commented 2 years ago

Is that still NOK @alanhamlett?

alanhamlett commented 2 years ago

@dosier make sure you have the Letsencrypt root cert installed on your machine:

https://letsencrypt.org/certificates/