x-pack elasticsearch

第一步:html

elasticsearch-6.3.0\modules\x-pack\x-pack-core目錄下找到x-pack-core-6.3.0.jar,複製一份出來留個備份java

 

第二步:新建兩個java文件分別命名爲LicenseVerifier.java和XPackBuild.javaapache

LicenseVerifier.javajson

package org.elasticsearch.license;
 
import java.nio.*;
import org.elasticsearch.common.bytes.*;
import java.util.*;
import java.security.*;
import org.elasticsearch.common.xcontent.*;
import org.apache.lucene.util.*;
import org.elasticsearch.core.internal.io.*;
import java.io.*;
 
 
public class LicenseVerifier
{
    public static boolean verifyLicense(final License license, final byte[] encryptedPublicKeyData) {
       return true;
    }
    
    public static boolean verifyLicense(final License license) {
         return true;
    }
}

XPackBuild.javabash

package org.elasticsearch.xpack.core;
 
import org.elasticsearch.common.io.*;
import java.net.*;
import org.elasticsearch.common.*;
import java.nio.file.*;
import java.io.*;
import java.util.jar.*;
 
 
public class XPackBuild
{
    public static final XPackBuild CURRENT;
    private String shortHash;
    private String date;
    
    @SuppressForbidden(reason = "looks up path of xpack.jar directly")
    static Path getElasticsearchCodebase() {
        final URL url = XPackBuild.class.getProtectionDomain().getCodeSource().getLocation();
        try {
            return PathUtils.get(url.toURI());
        }
        catch (URISyntaxException bogus) {
            throw new RuntimeException(bogus);
        }
    }
    
    XPackBuild(final String shortHash, final String date) {
        this.shortHash = shortHash;
        this.date = date;
    }
    
    public String shortHash() {
        return this.shortHash;
    }
    
    public String date() {
        return this.date;
    }
    
    static {
        final Path path = getElasticsearchCodebase();
        String shortHash = null;
        String date = null;
        Label_0157: {
           
            shortHash = "Unknown";
            date = "Unknown";
        }
        CURRENT = new XPackBuild(shortHash, date);
    }
}

第三步:編譯兩個文件app

mkdir -p org/elasticsearch/license/

mv LicenseVerifier.class org/elasticsearch/license/LicenseVerifier.class

javac -cp "/usr/local/ElasticSearch/elasticsearch-6.3.1/modules/x-pack/x-pack-core/x-pack-core-6.3.1.jar:/usr/local/ElasticSearch/elasticsearch-6.3.1/lib/lucene-core-7.3.1.jar:/usr/local/ElasticSearch/elasticsearch-6.3.1/lib/elasticsearch-6.3.1.jar:/usr/local/ElasticSearch/elasticsearch-6.3.1/lib/elasticsearch-core-6.3.1.jar"  /root/andychen/tmp/LicenseVerifier.java



mkdir -p org/elasticsearch/xpack/core/

mv LicenseVerifier.class org/elasticsearch/xpack/core/XPackBuild.class

javac -cp "/usr/local/ElasticSearch/elasticsearch-6.3.1/modules/x-pack/x-pack-core/x-pack-core-6.3.1.jar:/usr/local/ElasticSearch/elasticsearch-6.3.1/lib/lucene-core-7.3.1.jar:/usr/local/ElasticSearch/elasticsearch-6.3.1/lib/elasticsearch-6.3.1.jar:/usr/local/ElasticSearch/elasticsearch-6.3.1/lib/elasticsearch-core-6.3.1.jar" /root/andychen/tmp/XPackBuild.java

  

第四步:替換x-pack-core-6.3.0.jar裏的class文件(壓入)curl

mkdir -p org/elasticsearch/license/elasticsearch

mv LicenseVerifier.class org/elasticsearch/license/LicenseVerifier.classide

jar uvf /usr/local/ElasticSearch/elasticsearch-6.3.1/modules/x-pack/x-pack-core/x-pack-core-6.3.1.jar org/elasticsearch/license/LicenseVerifier.classui

 

mkdir -p org/elasticsearch/xpack/core/

mv LicenseVerifier.class org/elasticsearch/xpack/core/XPackBuild.class

jar uvf /usr/local/ElasticSearch/elasticsearch-6.3.1/modules/x-pack/x-pack-core/x-pack-core-6.3.1.jar org/elasticsearch/xpack/core/XPackBuild.class

 

第五步:

獲取 license 證書

https://license.elastic.co/registration 填些用戶名,郵箱(重要,獲取下載連接),Country選擇China,其餘信息隨意填寫

②打開郵箱獲取的地址,將下載後的文件更名爲license.json

③修改文件中的內容,將兩個屬性改成

將 "type":"basic" 替換爲 "type":"platinum"    # 基礎版變動爲鉑金版

將 "expiry_date_in_millis":1561420799999替換爲 "expiry_date_in_millis":3107746200000    # 1年變爲50年

④使用curl替換 license(license.json指的是剛剛下載修改屬性後的證書,要開啓elasticsearch服務)

curl -H "Content-Type: application/json" -XPUT 'http://192.168.7.245:9200/_xpack/license?acknowledge=true' -d @license.json

⑤若失敗,修改配置文件

xpack.security.enabled: false

破解成功後改回來

xpack.security.enabled: true

xpack.security.transport.ssl.enabled: true

⑥上傳後查看證書時間

curl -XGET http://192.168.7.245:9200/_license

 

參考: https://blog.csdn.net/xiaoyu_BD/article/details/81698882

API 使用帳號: https://www.elastic.co/guide/en/x-pack/current/http-clients.html 

相關文章
相關標籤/搜索