@@ -60,7 +60,8 @@ private void removeChangesListener(Context c) {
60
60
c .unregisterReceiver (mRestrictionsReceiver );
61
61
}
62
62
63
- private String hashConfig (String config ) {
63
+ private String hashConfig (String rawconfig ) {
64
+ String config = prepare (rawconfig );
64
65
MessageDigest digest ;
65
66
try {
66
67
digest = MessageDigest .getInstance ("SHA1" );
@@ -121,6 +122,10 @@ private void applyRestrictions(Context c) {
121
122
continue ;
122
123
}
123
124
125
+ /* we always use lower case uuid since Android UUID class will use present
126
+ * them that way */
127
+ uuid = uuid .toLowerCase (Locale .US );
128
+
124
129
if (uuid .equals (defaultprofile ))
125
130
defaultprofileProvisioned = true ;
126
131
@@ -188,22 +193,43 @@ private void applyRestrictions(Context c) {
188
193
* the authentication method and will also set the keystore alias
189
194
*/
190
195
private void addCertificateAlias (VpnProfile vpnProfile , String certAlias , Context c ) {
191
- if (certAlias == null || vpnProfile == null )
196
+ if (vpnProfile == null )
192
197
return ;
193
198
194
199
int oldType = vpnProfile .mAuthenticationType ;
195
200
String oldAlias = vpnProfile .mAlias ;
196
201
197
- switch (vpnProfile .mAuthenticationType )
202
+ if (!TextUtils .isEmpty (certAlias )) {
203
+ switch (vpnProfile .mAuthenticationType )
204
+ {
205
+ case VpnProfile .TYPE_PKCS12 :
206
+ case VpnProfile .TYPE_CERTIFICATES :
207
+ vpnProfile .mAuthenticationType = VpnProfile .TYPE_KEYSTORE ;
208
+ break ;
209
+ case VpnProfile .TYPE_USERPASS_CERTIFICATES :
210
+ case VpnProfile .TYPE_USERPASS_PKCS12 :
211
+ vpnProfile .mAuthenticationType = VpnProfile .TYPE_USERPASS_KEYSTORE ;
212
+ break ;
213
+ }
214
+
215
+ } else
198
216
{
199
- case VpnProfile .TYPE_PKCS12 :
200
- case VpnProfile .TYPE_CERTIFICATES :
201
- vpnProfile .mAuthenticationType = VpnProfile .TYPE_KEYSTORE ;
202
- break ;
203
- case VpnProfile .TYPE_USERPASS_CERTIFICATES :
204
- case VpnProfile .TYPE_USERPASS_PKCS12 :
205
- vpnProfile .mAuthenticationType = VpnProfile .TYPE_USERPASS_KEYSTORE ;
206
- break ;
217
+ /* Alias is null, return to non keystore method */
218
+ boolean pkcs12present = !TextUtils .isEmpty (vpnProfile .mPKCS12Filename );
219
+ switch (vpnProfile .mAuthenticationType ) {
220
+ case VpnProfile .TYPE_USERPASS_KEYSTORE :
221
+ if (pkcs12present )
222
+ vpnProfile .mAuthenticationType = VpnProfile .TYPE_USERPASS_PKCS12 ;
223
+ else
224
+ vpnProfile .mAuthenticationType = VpnProfile .TYPE_USERPASS_CERTIFICATES ;
225
+ break ;
226
+ case VpnProfile .TYPE_KEYSTORE :
227
+ if (pkcs12present )
228
+ vpnProfile .mAuthenticationType = VpnProfile .TYPE_PKCS12 ;
229
+ else
230
+ vpnProfile .mAuthenticationType = VpnProfile .TYPE_CERTIFICATES ;
231
+ break ;
232
+ }
207
233
}
208
234
vpnProfile .mAlias = certAlias ;
209
235
0 commit comments