示例消息
error XA4252: Insecure HTTP Maven repository URL 'http://repo.example.com/maven2/' is not allowed. Use an HTTPS URL, or set AllowInsecureHttp="true" metadata on the item to override this check.
Issue
<AndroidMavenLibrary>项指定 Maven 存储库 URL 时使用 https:// 而不是 http://。
通过明文 HTTP 下载构件存在安全风险,因为连接未加密,容易受到中间人攻击,并可能导致供应链遭到入侵。
此检查与 Gradle(allowInsecureProtocol)和 Maven(<blocked>http://*</blocked>)中的默认行为一致,以实现纵深防御和供应链加固。
解决方案
尽可能使用 Maven 存储库的 HTTPS URL:
<ItemGroup>
<AndroidMavenLibrary Include="com.example:mylib" Version="1.0.0" Repository="https://repo.example.com/maven2/" />
</ItemGroup>
如果存储库不支持 HTTPS,并且你了解其中的安全影响,请将其设置为 AllowInsecureHttp="true",以明确选择启用不安全的 HTTP:
<ItemGroup>
<AndroidMavenLibrary Include="com.example:mylib" Version="1.0.0" Repository="http://repo.example.com/maven2/" AllowInsecureHttp="true" />
</ItemGroup>