Skip to content

Commit 742f960

Browse files
Vincent DufrasnesLinuxJedi
authored andcommitted
[MDEV-30178] Explicit errors on required secured transport
The error message for user connections using insecure transport when secured transport is required is very uninformative and doesn't mention the requirement of secure transport at all. To make the error message more relevant, introduce a new error 'ER_SECURE_TRANSPORT_REQUIRED', copy of MySQL error message with the error code 08004 (SQL-server rejected establishment SQL-connection). Move the code of 'require_secure_transport' to be executed before authentication verification, as it's not part of authentication but rather verifying if connection should be allowed in the first place. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
1 parent 038d292 commit 742f960

File tree

5 files changed

+329
-23
lines changed

5 files changed

+329
-23
lines changed

mysql-test/main/require_secure_transport.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE TABLE t1 (t int(1));
22
SET GLOBAL require_secure_transport=ON;
3-
ERROR 28000: Access denied for user 'root'@'localhost' (using password: NO)
3+
ERROR HY000: Connections using insecure transport are prohibited while --require_secure_transport=ON.
44
connection default;
55
SET GLOBAL require_secure_transport=OFF;
66
disconnect without_ssl;

mysql-test/main/require_secure_transport.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CREATE TABLE t1 (t int(1));
33
SET GLOBAL require_secure_transport=ON;
44
--disable_query_log
5-
--error ER_ACCESS_DENIED_ERROR
5+
--error ER_SECURE_TRANSPORT_REQUIRED
66
connect without_ssl,localhost,root,,,,,TCP NOSSL;
77
--enable_query_log
88
connection default;

sql/share/errmsg-utf8.txt

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11001,6 +11001,304 @@ ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS
1100111001
eng "Do not support online operation on table with GIS index"
1100211002
spa "No soporta operación en línea en tabla con índice GIS"
1100311003
sw "Haiwezi kufanya operesheni ya mtandaoni kwenye jedwali na faharisi ya GIS"
11004+
11005+
ER_MYSQL_3061
11006+
eng ""
11007+
11008+
ER_MYSQL_3062
11009+
eng ""
11010+
11011+
ER_MYSQL_3063
11012+
eng ""
11013+
11014+
ER_MYSQL_3064
11015+
eng ""
11016+
11017+
ER_MYSQL_3065
11018+
eng ""
11019+
11020+
ER_MYSQL_3066
11021+
eng ""
11022+
11023+
ER_MYSQL_3067
11024+
eng ""
11025+
11026+
ER_MYSQL_3068
11027+
eng ""
11028+
11029+
ER_MYSQL_3069
11030+
eng ""
11031+
11032+
ER_MYSQL_3070
11033+
eng ""
11034+
11035+
ER_MYSQL_3071
11036+
eng ""
11037+
11038+
ER_MYSQL_3072
11039+
eng ""
11040+
11041+
ER_MYSQL_3073
11042+
eng ""
11043+
11044+
ER_MYSQL_3074
11045+
eng ""
11046+
11047+
ER_MYSQL_3075
11048+
eng ""
11049+
11050+
ER_MYSQL_3076
11051+
eng ""
11052+
11053+
ER_MYSQL_3077
11054+
eng ""
11055+
11056+
ER_MYSQL_3078
11057+
eng ""
11058+
11059+
ER_MYSQL_3079
11060+
eng ""
11061+
11062+
ER_MYSQL_3080
11063+
eng ""
11064+
11065+
ER_MYSQL_3081
11066+
eng ""
11067+
11068+
ER_MYSQL_3082
11069+
eng ""
11070+
11071+
ER_MYSQL_3083
11072+
eng ""
11073+
11074+
ER_MYSQL_3084
11075+
eng ""
11076+
11077+
ER_MYSQL_3085
11078+
eng ""
11079+
11080+
ER_MYSQL_3086
11081+
eng ""
11082+
11083+
ER_MYSQL_3087
11084+
eng ""
11085+
11086+
ER_MYSQL_3088
11087+
eng ""
11088+
11089+
ER_MYSQL_3089
11090+
eng ""
11091+
11092+
ER_MYSQL_3090
11093+
eng ""
11094+
11095+
ER_MYSQL_3091
11096+
eng ""
11097+
11098+
ER_MYSQL_3092
11099+
eng ""
11100+
11101+
ER_MYSQL_3093
11102+
eng ""
11103+
11104+
ER_MYSQL_3094
11105+
eng ""
11106+
11107+
ER_MYSQL_3095
11108+
eng ""
11109+
11110+
ER_MYSQL_3096
11111+
eng ""
11112+
11113+
ER_MYSQL_3097
11114+
eng ""
11115+
11116+
ER_MYSQL_3098
11117+
eng ""
11118+
11119+
ER_MYSQL_3099
11120+
eng ""
11121+
11122+
ER_MYSQL_3100
11123+
eng ""
11124+
11125+
ER_MYSQL_3101
11126+
eng ""
11127+
11128+
ER_MYSQL_3102
11129+
eng ""
11130+
11131+
ER_MYSQL_3103
11132+
eng ""
11133+
11134+
ER_MYSQL_3104
11135+
eng ""
11136+
11137+
ER_MYSQL_3105
11138+
eng ""
11139+
11140+
ER_MYSQL_3106
11141+
eng ""
11142+
11143+
ER_MYSQL_3107
11144+
eng ""
11145+
11146+
ER_MYSQL_3108
11147+
eng ""
11148+
11149+
ER_MYSQL_3109
11150+
eng ""
11151+
11152+
ER_MYSQL_3110
11153+
eng ""
11154+
11155+
ER_MYSQL_3111
11156+
eng ""
11157+
11158+
ER_MYSQL_3112
11159+
eng ""
11160+
11161+
ER_MYSQL_3113
11162+
eng ""
11163+
11164+
ER_MYSQL_3114
11165+
eng ""
11166+
11167+
ER_MYSQL_3115
11168+
eng ""
11169+
11170+
ER_MYSQL_3116
11171+
eng ""
11172+
11173+
ER_MYSQL_3117
11174+
eng ""
11175+
11176+
ER_MYSQL_3118
11177+
eng ""
11178+
11179+
ER_MYSQL_3119
11180+
eng ""
11181+
11182+
ER_MYSQL_3120
11183+
eng ""
11184+
11185+
ER_MYSQL_3121
11186+
eng ""
11187+
11188+
ER_MYSQL_3122
11189+
eng ""
11190+
11191+
ER_MYSQL_3123
11192+
eng ""
11193+
11194+
ER_MYSQL_3124
11195+
eng ""
11196+
11197+
ER_MYSQL_3125
11198+
eng ""
11199+
11200+
ER_MYSQL_3126
11201+
eng ""
11202+
11203+
ER_MYSQL_3127
11204+
eng ""
11205+
11206+
ER_MYSQL_3128
11207+
eng ""
11208+
11209+
ER_MYSQL_3129
11210+
eng ""
11211+
11212+
ER_MYSQL_3130
11213+
eng ""
11214+
11215+
ER_MYSQL_3131
11216+
eng ""
11217+
11218+
ER_MYSQL_3132
11219+
eng ""
11220+
11221+
ER_MYSQL_3133
11222+
eng ""
11223+
11224+
ER_MYSQL_3134
11225+
eng ""
11226+
11227+
ER_MYSQL_3135
11228+
eng ""
11229+
11230+
ER_MYSQL_3136
11231+
eng ""
11232+
11233+
ER_MYSQL_3137
11234+
eng ""
11235+
11236+
ER_MYSQL_3138
11237+
eng ""
11238+
11239+
ER_MYSQL_3139
11240+
eng ""
11241+
11242+
ER_MYSQL_3140
11243+
eng ""
11244+
11245+
ER_MYSQL_3141
11246+
eng ""
11247+
11248+
ER_MYSQL_3142
11249+
eng ""
11250+
11251+
ER_MYSQL_3143
11252+
eng ""
11253+
11254+
ER_MYSQL_3144
11255+
eng ""
11256+
11257+
ER_MYSQL_3145
11258+
eng ""
11259+
11260+
ER_MYSQL_3146
11261+
eng ""
11262+
11263+
ER_MYSQL_3147
11264+
eng ""
11265+
11266+
ER_MYSQL_3148
11267+
eng ""
11268+
11269+
ER_MYSQL_3149
11270+
eng ""
11271+
11272+
ER_MYSQL_3150
11273+
eng ""
11274+
11275+
ER_MYSQL_3151
11276+
eng ""
11277+
11278+
ER_MYSQL_3152
11279+
eng ""
11280+
11281+
ER_MYSQL_3153
11282+
eng ""
11283+
11284+
ER_MYSQL_3154
11285+
eng ""
11286+
11287+
ER_MYSQL_3155
11288+
eng ""
11289+
11290+
ER_MYSQL_3156
11291+
eng ""
11292+
11293+
ER_MYSQL_3157
11294+
eng ""
11295+
11296+
ER_MYSQL_3158
11297+
eng ""
11298+
11299+
ER_SECURE_TRANSPORT_REQUIRED 08004
11300+
eng "Connections using insecure transport are prohibited while --require_secure_transport=ON."
11301+
1100411302
# MariaDB extra error numbers starts from 4000
1100511303
skip-to-error-number 4000
1100611304

sql/sql_acl.cc

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14170,8 +14170,8 @@ static void server_mpvio_info(MYSQL_PLUGIN_VIO *vio,
1417014170

1417114171
static bool acl_check_ssl(THD *thd, const ACL_USER *acl_user)
1417214172
{
14173-
Vio *vio= thd->net.vio;
1417414173
#ifdef HAVE_OPENSSL
14174+
Vio *vio= thd->net.vio;
1417514175
SSL *ssl= (SSL *) vio->ssl_arg;
1417614176
X509 *cert;
1417714177
#endif
@@ -14183,26 +14183,8 @@ static bool acl_check_ssl(THD *thd, const ACL_USER *acl_user)
1418314183
if X509 certificate attributes are OK
1418414184
*/
1418514185
switch (acl_user->ssl_type) {
14186-
case SSL_TYPE_NOT_SPECIFIED: // Impossible
14187-
case SSL_TYPE_NONE: // SSL is not required
14188-
if (opt_require_secure_transport)
14189-
{
14190-
enum enum_vio_type type= vio_type(vio);
14191-
#ifdef HAVE_OPENSSL
14192-
return type != VIO_TYPE_SSL &&
14193-
#ifndef _WIN32
14194-
type != VIO_TYPE_SOCKET;
14195-
#else
14196-
type != VIO_TYPE_NAMEDPIPE;
14197-
#endif
14198-
#else
14199-
#ifndef _WIN32
14200-
return type != VIO_TYPE_SOCKET;
14201-
#else
14202-
return type != VIO_TYPE_NAMEDPIPE;
14203-
#endif
14204-
#endif
14205-
}
14186+
case SSL_TYPE_NOT_SPECIFIED: // Impossible
14187+
case SSL_TYPE_NONE: // SSL is not required FOR THIS SPECIFIC USER
1420614188
return 0;
1420714189
#ifdef HAVE_OPENSSL
1420814190
case SSL_TYPE_ANY: // Any kind of SSL is ok

0 commit comments

Comments
 (0)