From b2d9728e16dd5c55b8d1528fd37a58cf9790bc76 Mon Sep 17 00:00:00 2001
From: HW_TaoChen <boby.chen@huawei.com>
Date: Wed, 30 Dec 2020 16:57:48 +0800
Subject: [PATCH] atune: support for Go 1.15

Signed-off-by: hanxinke <hanxinke@huawei.com>
---
 Makefile                                      | 40 ++++++++++---------
 .../collections/stack/stack.go                |  4 +-
 vendor/modules.txt                            | 19 +++++++++
 3 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/Makefile b/Makefile
index 68f6252..08eb3e5 100755
--- a/Makefile
+++ b/Makefile
@@ -125,17 +125,19 @@ restcerts:
 	openssl genrsa -out $(REST_CERT_PATH)/ca.key 2048
 	openssl req -new -x509 -days 3650 -subj "/CN=ca" -key $(REST_CERT_PATH)/ca.key -out $(REST_CERT_PATH)/ca.crt
 	openssl genrsa -out $(REST_CERT_PATH)/server.key 2048
+	cp /etc/pki/tls/openssl.cnf $(REST_CERT_PATH)
 	@if test $(REST_IP_ADDR) == localhost; then \
-		openssl req -new -subj "/CN=localhost" -key $(REST_CERT_PATH)/server.key -out $(REST_CERT_PATH)/server.csr; \
-		openssl x509 -req -sha256 -CA $(REST_CERT_PATH)/ca.crt -CAkey $(REST_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-			-in $(REST_CERT_PATH)/server.csr -out $(REST_CERT_PATH)/server.crt; \
+		echo "[SAN]\nsubjectAltName=DNS:$(REST_IP_ADDR)" >> $(REST_CERT_PATH)/openssl.cnf; \
+		echo "subjectAltName=DNS:$(REST_IP_ADDR)" > $(REST_CERT_PATH)/extfile.cnf; \
 	else \
-		openssl req -new -subj "/CN=$(REST_IP_ADDR)" -key $(REST_CERT_PATH)/server.key -out $(REST_CERT_PATH)/server.csr; \
+		echo "[SAN]\nsubjectAltName=IP:$(REST_IP_ADDR)" >> $(REST_CERT_PATH)/openssl.cnf; \
 		echo "subjectAltName=IP:$(REST_IP_ADDR)" > $(REST_CERT_PATH)/extfile.cnf; \
-		openssl x509 -req -sha256 -CA $(REST_CERT_PATH)/ca.crt -CAkey $(REST_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-			-extfile $(REST_CERT_PATH)/extfile.cnf -in $(REST_CERT_PATH)/server.csr -out $(REST_CERT_PATH)/server.crt; \
 	fi
-	rm -rf $(REST_CERT_PATH)/*.srl $(REST_CERT_PATH)/*.csr $(REST_CERT_PATH)/extfile.cnf
+	openssl req -new -subj "/CN=$(REST_IP_ADDR)" -config $(REST_CERT_PATH)/openssl.cnf \
+		-key $(REST_CERT_PATH)/server.key -out $(REST_CERT_PATH)/server.csr
+	openssl x509 -req -sha256 -CA $(REST_CERT_PATH)/ca.crt -CAkey $(REST_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
+		-extfile $(REST_CERT_PATH)/extfile.cnf -in $(REST_CERT_PATH)/server.csr -out $(REST_CERT_PATH)/server.crt
+	rm -rf $(REST_CERT_PATH)/*.srl $(REST_CERT_PATH)/*.csr $(REST_CERT_PATH)/*.cnf
 	@echo "END GENERATE REST CERTS"
 
 enginecerts:
@@ -145,20 +147,22 @@ enginecerts:
 		openssl genrsa -out $(ENGINE_CERT_PATH)/ca.key 2048; \
 		openssl req -new -x509 -days 3650 -subj "/CN=ca" -key $(ENGINE_CERT_PATH)/ca.key -out $(ENGINE_CERT_PATH)/ca.crt; \
 	fi
+	cp /etc/pki/tls/openssl.cnf $(ENGINE_CERT_PATH)
+	@if test $(ENGINE_IP_ADDR) == localhost; then \
+		echo "[SAN]\nsubjectAltName=DNS:$(ENGINE_IP_ADDR)" >> $(ENGINE_CERT_PATH)/openssl.cnf; \
+		echo "subjectAltName=DNS:$(ENGINE_IP_ADDR)" > $(ENGINE_CERT_PATH)/extfile.cnf; \
+	else \
+		echo "[SAN]\nsubjectAltName=IP:$(ENGINE_IP_ADDR)" >> $(ENGINE_CERT_PATH)/openssl.cnf; \
+		echo "subjectAltName=IP:$(ENGINE_IP_ADDR)" > $(ENGINE_CERT_PATH)/extfile.cnf; \
+	fi
 	@for name in server client; do \
 		openssl genrsa -out $(ENGINE_CERT_PATH)/$$name.key 2048; \
-		if test $(ENGINE_IP_ADDR) == localhost; then \
-			openssl req -new -subj "/CN=localhost" -key $(ENGINE_CERT_PATH)/$$name.key -out $(ENGINE_CERT_PATH)/$$name.csr; \
-			openssl x509 -req -sha256 -CA $(ENGINE_CERT_PATH)/ca.crt -CAkey $(ENGINE_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-				-in $(ENGINE_CERT_PATH)/$$name.csr -out $(ENGINE_CERT_PATH)/$$name.crt; \
-		else \
-			openssl req -new -subj "/CN=$(ENGINE_IP_ADDR)" -key $(ENGINE_CERT_PATH)/$$name.key -out $(ENGINE_CERT_PATH)/$$name.csr; \
-			echo "subjectAltName=IP:$(ENGINE_IP_ADDR)" > $(ENGINE_CERT_PATH)/extfile.cnf; \
-			openssl x509 -req -sha256 -CA $(ENGINE_CERT_PATH)/ca.crt -CAkey $(ENGINE_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-				-extfile $(ENGINE_CERT_PATH)/extfile.cnf -in $(ENGINE_CERT_PATH)/$$name.csr -out $(ENGINE_CERT_PATH)/$$name.crt; \
-		fi; \
+		openssl req -new -subj "/CN=$(ENGINE_IP_ADDR)" -config $(ENGINE_CERT_PATH)/openssl.cnf \
+			-key $(ENGINE_CERT_PATH)/$$name.key -out $(ENGINE_CERT_PATH)/$$name.csr; \
+		openssl x509 -req -sha256 -CA $(ENGINE_CERT_PATH)/ca.crt -CAkey $(ENGINE_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
+			-extfile $(ENGINE_CERT_PATH)/extfile.cnf -in $(ENGINE_CERT_PATH)/$$name.csr -out $(ENGINE_CERT_PATH)/$$name.crt; \
 	done
-	rm -rf $(ENGINE_CERT_PATH)/*.srl $(ENGINE_CERT_PATH)/*.csr $(ENGINE_CERT_PATH)/extfile.cnf
+	rm -rf $(ENGINE_CERT_PATH)/*.srl $(ENGINE_CERT_PATH)/*.csr $(ENGINE_CERT_PATH)/*.cnf
 	@echo "END GENERATE ENGINE CERTS"
 
 env:
diff --git a/vendor/github.com/golang-collections/collections/stack/stack.go b/vendor/github.com/golang-collections/collections/stack/stack.go
index 04063df..a433fc9 100644
--- a/vendor/github.com/golang-collections/collections/stack/stack.go
+++ b/vendor/github.com/golang-collections/collections/stack/stack.go
@@ -8,7 +8,7 @@ type (
 	node struct {
 		value interface{}
 		prev *node
-	}	
+	}
 )
 // Create a new stack
 func New() *Stack {
@@ -30,7 +30,7 @@ func (this *Stack) Pop() interface{} {
 	if this.length == 0 {
 		return nil
 	}
-	
+
 	n := this.top
 	this.top = n.prev
 	this.length--
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 5807785..b45918a 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,20 +1,27 @@
 # github.com/antlr/antlr4 v0.0.0-20190726171924-e4737db19f4f
+## explicit
 github.com/antlr/antlr4/runtime/Go/antlr
 # github.com/bndr/gotabulate v1.1.2
+## explicit
 github.com/bndr/gotabulate
 # github.com/caibirdme/yql v0.0.0-20190801103415-238f3c90b514
+## explicit
 github.com/caibirdme/yql
 github.com/caibirdme/yql/internal/grammar
 github.com/caibirdme/yql/internal/stack
 # github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
+## explicit
 github.com/coreos/go-systemd/daemon
 # github.com/go-ini/ini v1.42.0
+## explicit
 github.com/go-ini/ini
 # github.com/go-xorm/xorm v0.7.4
+## explicit
 github.com/go-xorm/xorm
 # github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
 github.com/golang-collections/collections/stack
 # github.com/golang/protobuf v1.3.1
+## explicit
 github.com/golang/protobuf/proto
 github.com/golang/protobuf/protoc-gen-go/descriptor
 github.com/golang/protobuf/ptypes
@@ -26,10 +33,13 @@ github.com/juju/errors
 # github.com/konsorten/go-windows-terminal-sequences v1.0.1
 github.com/konsorten/go-windows-terminal-sequences
 # github.com/mattn/go-sqlite3 v1.11.0
+## explicit
 github.com/mattn/go-sqlite3
 # github.com/mitchellh/mapstructure v1.1.2
+## explicit
 github.com/mitchellh/mapstructure
 # github.com/newm4n/grool v1.0.2
+## explicit
 github.com/newm4n/grool/antlr
 github.com/newm4n/grool/antlr/parser
 github.com/newm4n/grool/builder
@@ -38,11 +48,16 @@ github.com/newm4n/grool/engine
 github.com/newm4n/grool/model
 github.com/newm4n/grool/pkg
 # github.com/sirupsen/logrus v1.4.2
+## explicit
 github.com/sirupsen/logrus
 github.com/sirupsen/logrus/hooks/syslog
+# github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
+## explicit
 # github.com/urfave/cli v1.20.0
+## explicit
 github.com/urfave/cli
 # golang.org/x/net v0.0.0-20190724013045-ca1201d0de80
+## explicit
 golang.org/x/net/context
 golang.org/x/net/http/httpguts
 golang.org/x/net/http2
@@ -60,6 +75,7 @@ golang.org/x/text/unicode/norm
 # google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107
 google.golang.org/genproto/googleapis/rpc/status
 # google.golang.org/grpc v1.22.0
+## explicit
 google.golang.org/grpc
 google.golang.org/grpc/balancer
 google.golang.org/grpc/balancer/base
@@ -95,7 +111,10 @@ google.golang.org/grpc/serviceconfig
 google.golang.org/grpc/stats
 google.golang.org/grpc/status
 google.golang.org/grpc/tap
+# gopkg.in/ini.v1 v1.48.0
+## explicit
 # gopkg.in/yaml.v2 v2.2.2
+## explicit
 gopkg.in/yaml.v2
 # xorm.io/builder v0.3.5
 xorm.io/builder
-- 
2.23.0

