/* Creates TLS connection between this client and a server and performs a remote
 * attestation of the server before exchanging few a exemplary messages with it
 */
Creates TLS connection between this client and a server and performs a remote
attestation of the server before exchanging few a exemplary messages with it
/ * Creates TLS connection between this client and a server and performs a remote * attestation of the server before exchanging few a exemplary messages with it * /
func TestTLSConn(connectoraddress, rootCACertFile string) {
	var timeout = 10 * time.Second
	servercert, err := ioutil.ReadFile(rootCACertFile)
	if err != nil {
		log.Error("[Testclient] Could find root CA cert file.")
		return
	}
	roots := x509.NewCertPool()
	success := roots.AppendCertsFromPEM(servercert)
	if !success {
		log.Error("[Testclient] Could not add servercert to root CAs.")
		return
	}
	conf := &tls.Config{
		RootCAs: roots,
	}
	conn, err := atls.Dial("tcp", connectoraddress, conf)
	if err != nil {
		log.Error("[Testclient] failed to dial server. \n", err)
		return
	}
	defer conn.Close()
	_ = conn.SetReadDeadline(time.Now().Add(timeout))
	_, err = conn.Write([]byte("hello\n"))
	if err != nil {
		log.Error("[Testclient] failed to write. \n", err)
		return
	}
	buf := make([]byte, 100)
	n, err := conn.Read(buf)
	if err != nil {
		log.Error("[Testclient] failed to read. \n", err)
		return
	}
	log.Info("[Testclient] received: " + string(buf[:n]))
}
func TestTLSConn ( connectoraddress , rootCACertFile string ) { var timeout = 10 * time . Second servercert , err := ioutil . ReadFile ( rootCACertFile ) if err != nil { log . Error ( " " ) return } roots := x509 . NewCertPool ( ) success := roots . AppendCertsFromPEM ( servercert ) if ! success { log . Error ( " " ) return } conf := & tls . Config { RootCAs : roots , } conn , err := atls . Dial ( " " , connectoraddress , conf ) if err != nil { log . Error ( " \n " , err ) return } defer conn . Close ( ) _ = conn . SetReadDeadline ( time . Now ( ) . Add ( timeout ) ) _ , err = conn . Write ( [ ] byte ( " \n " ) ) if err != nil { log . Error ( " \n " , err ) return } buf := make ( [ ] byte , 100 ) n , err := conn . Read ( buf ) if err != nil { log . Error ( " \n " , err ) return } log . Info ( " " + string ( buf [ : n ] ) ) }
Creates TLS connection between this client and a server and performs a remote
attestation of the server before exchanging few a exemplary messages with it
Creates TLS connection between this client and a server and performs a remote attestation of the server before exchanging few a exemplary messages with it
// get server cert // Create TLS config with server as root CA //InsecureSkipVerify: true, // write sth // read sth