java - Elasticsearch 异常 [type=illegal_argument_exception, reason=Provided password hash uses [NOOP] but the configured hashing algorithm is [BCRYPT]]
问题描述
我正在尝试使用 Java Spring Boot 应用程序创建一个新的 Elasticsearch 用户。但显示以下错误:
Elasticsearch 异常 [type=illegal_argument_exception, reason=Provided password hash uses [NOOP] but the configured hashing algorithm is [BCRYPT]]
我正在执行以下操作:
public String create(ElasticUser newUser) {
try {
byte[] salt = new byte[16];
RANDOM.nextBytes(salt);
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2withHMACSHA512");
PBEKeySpec keySpec = new PBEKeySpec("password".toCharArray(), salt, 10000, 256);
final byte[] pbkdfEncoded = secretKeyFactory.generateSecret(keySpec).getEncoded();
char[] passwordHash = ("{PBKDF2}10000$" + Base64.getEncoder().encodeToString(salt)
+ "$" + Base64.getEncoder().encodeToString(pbkdfEncoded)).toCharArray();
User user = new User(newUser.getName(), new ArrayList<>(Arrays.asList("normal_user")));
PutUserRequest request = PutUserRequest.withPasswordHash(user
, passwordHash
, true
, RefreshPolicy.NONE);
PutUserResponse response = restHighLevelClient.security().putUser(request, RequestOptions.DEFAULT);
return response.toString();
} catch(Exception e) {
return "Error: " + e.getMessage();
}
}
关于这个问题的任何想法?
解决方案
推荐阅读
- python - Django 不使用来自 settings.py 的数据库
- php - Docker pdo_oci 不可用
- java - Java:创建地图列表列表
- angular - ng xi18n:提取字符串时排除 node_modules 中的代码
- sql - CREATE TABLE 中的语法错误,没有任何表创建但在过程创建中
- php - 如何比较来自 php 中嵌套循环的外部变量
- ios - iOS Swift NSCoreDataCoreSpotlightDelegate 崩溃:“无法添加商店”
- android - Android 10 后台位置更新
- r - Stargazer 表直接转换成 pdf 表不显示
- sql - 有没有办法将 CTE 输出插入到 SQL Server 中的#mytemp