2 // Copyright © 2013-2018 Guy M. Allard
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 Connect and Disconnect from a STOMP broker with a TLS connection, use case 1.
20 TLS Use Case 1 - client does *not* authenticate broker.
22 Subcase 1.A - Message broker configuration does *not* require client authentication
24 - Expect connection success
26 Subcase 1.B - Message broker configuration *does* require client authentication
28 - Expect connection failure (broker must be sent a valid client certificate)
33 STOMP_PORT=61611 ./tlsuc1
43 // sngecomm methods are used specifically for these example clients.
44 "github.com/gmallard/stompngo_examples/sngecomm"
51 ll
= log
.New(os
.Stdout
, "TLSU1 ", log
.Ldate|log
.Lmicroseconds|log
.Lshortfile
)
56 // Connect to a STOMP broker using TLS and disconnect.
61 ll
.Printf("%stag:%s connsess:%s starts\n",
62 exampid
, tag
, sngecomm
.Lcs
)
66 tc
.InsecureSkipVerify
= true // Do *not* check the server's certificate
68 // Usually one will use the default cipher suites that go provides.
69 // However, if a custom cipher squite list is needed/required this
70 // is how it is accomplished.
71 if sngecomm
.UseCustomCiphers() { // Set custom cipher suite list
72 tc
.CipherSuites
= append(tc
.CipherSuites
, sngecomm
.CustomCiphers()...)
75 // Standard example TLS connect sequence
76 n
, conn
, e
:= sngecomm
.CommonTLSConnect(exampid
, tag
, ll
, tc
)
78 ll
.Fatalf("%stag:%s connsess:%s main_on_connect error:%v",
79 exampid
, tag
, sngecomm
.Lcs
,
80 e
.Error()) // Handle this ......
84 sngecomm
.DumpTLSConfig(exampid
, tc
, nc
)
86 // *NOTE* application specific functionaltiy starts here!
88 // *NOTE* application specific functionaltiy ends here!
90 // Standard example disconnect sequence
91 e
= sngecomm
.CommonDisconnect(n
, conn
, exampid
, tag
, ll
)
93 ll
.Fatalf("%s %s\n", exampid
, e
.Error()) // Handle this ......
96 ll
.Printf("%stag:%s connsess:%s main_elapsed:%v\n",
97 exampid
, tag
, conn
.Session(),