repchain2.0-update46:给系统管理服务的Https服务增加是否启动客户端的证书认证,启动服务时必须是否使用客户端认证,true和false,true表示使用客户端认证。

This commit is contained in:
jiangbuyun 2022-06-05 16:04:21 +08:00
parent 1d144df9b1
commit b7956dabee
2 changed files with 13 additions and 11 deletions

View File

@ -5,15 +5,17 @@ import rep.app.management.{ManagementServer, ReasonOfStartup, RepChainMgr}
object RepChain_Management {
def main(args: Array[String]): Unit = {
if(args!=null && args.length>1){
if(args!=null && args.length>2){
val port_str = args(0)
val port = Integer.parseInt(port_str)
val ssl_str = args(1)
val ssl_mode = Integer.parseInt(ssl_str)
val useClientAuth_str = args(2)
val useClientAuth = if(useClientAuth_str.equalsIgnoreCase("true")) true else false
val system = ActorSystem("RepChain-Management-Server")
system.actorOf(ManagementServer.props(port,ssl_mode), "ManagementServer")
if(args.length > 2){
for(i<-1 to args.length-1){
system.actorOf(ManagementServer.props(port,ssl_mode,useClientAuth), "ManagementServer")
if(args.length > 3){
for(i<-3 to args.length-1){
System.out.println(s"Start start node(${args(i)})...")
RepChainMgr.Startup4Single(args(i),ReasonOfStartup.Manual)
System.out.println(s"Now start to check whether the node(${args(i)}) is started successfully...")
@ -21,7 +23,7 @@ object RepChain_Management {
}
}
}else{
System.out.println("Please enter Service port number and ssl mode to start0=http;1=https;2=https(gmssl)" +
System.out.println("Please enter Service port number and ssl mode,use ClientAuth to start0=http;1=https;2=https(gmssl),use ClientAuth is Boolean," +
"Node name is optionalthe system will start the node automatically for exampleRepChain_Management 8080 0 [nodeName]")
}
}

View File

@ -10,14 +10,14 @@ import rep.log.RepLogger
import rep.proto.rc2.Event
object ManagementServer {
def props(port: Int,ssl_mode: Int): Props = Props(classOf[ManagementServer], port,ssl_mode)
def props(port: Int,ssl_mode: Int,useClientAuth:Boolean): Props = Props(classOf[ManagementServer], port,ssl_mode,useClientAuth:Boolean)
/** 启动管理服务
*
* @param sys ActorSystem
* @param
*/
def start(sys: ActorSystem, port: Int,sslMode:Int) {
def start(sys: ActorSystem, port: Int,sslMode:Int,useClientAuth:Boolean) {
implicit val system = sys
implicit val executionContext = system.dispatcher
@ -44,8 +44,8 @@ object ManagementServer {
engine.setEnabledCipherSuites(cipherSuite.toArray)
engine.setEnabledProtocols(Array(
sys.settings.config.getString("akka.remote.artery.ssl.config-ssl-engine.protocol")))
engine.setNeedClientAuth(false)
engine.setWantClientAuth(false)
engine.setNeedClientAuth(useClientAuth)
//engine.setWantClientAuth(true)
engine
})
@ -70,9 +70,9 @@ object ManagementServer {
}
}
class ManagementServer(port: Int,sslMode:Int) extends Actor {
class ManagementServer(port: Int,sslMode:Int,useClientAuth:Boolean) extends Actor {
override def preStart(): Unit = {
ManagementServer.start(context.system, port,sslMode)
ManagementServer.start(context.system, port,sslMode,useClientAuth)
}
def receive = {