简体   繁体   中英

Using insecure protocols with repositories build.gradle react native

I'm trying to install this library https://github.com/januslo/react-native-bluetooth-escpos-printer after manually linking it to the project I got this error

A problem occurred configuring project ':react-native-bluetooth-escpos-printer'.

Could not resolve all dependencies for configuration ':react-native-bluetooth-escpos-printer:classpath'. Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'BintrayJCenter( http://jcenter.bintray.com/ )' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.

The issue is probably here in this file build.gradle

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(':react-native-bluetooth-escpos-printer')
    ...
    }

I'm aware that I should use allowInsecureProtocol but as I'm not familiar with Java I'm not sure how to achieve the same result as in the code below

maven { url "http://myorg.example/repo"; allowInsecureProtocol = true }

The real problem is this line:

jcenter { url "http://jcenter.bintray.com/" }

It is line #3 of https://github.com/januslo/react-native-bluetooth-escpos-printer/blob/master/android/build.gradle

I think it should be:

jcenter { url "https://jcenter.bintray.com/" }

or

jcenter { url "http://jcenter.bintray.com/"; allowInsecureProtocol = true }

Note that Gradle (deliberately!) doesn't provide a way to turn these checks off except on a case-by-case basis. The docs say:

"For security purposes this intentionally requires a user to opt-in to using insecure protocols on case by case basis.

Gradle intentionally does not offer a global system/gradle property that allows a universal disable of this check."

The issue is the use of insecure jcentre endpoints. Consider using the system-defined endpoints which are loaded automatically.

Instead of jcenter { url "http://jcenter.bintray.com/" }

use jcenter()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM