Layer 7 Mobile API Gateway: Unable to post to register_device: Hostname not verified

book

Article ID: 102811

calendar_today

Updated On:

Products

CA Rapid App Security CA API Gateway

Issue/Introduction

When using the Mobile SDK and launching an app the below error is received:


Unable to post to register_device: Hostname XXXXXXXX not verified: 

certificate: sha1/MMJ610v359r/3qXRqHG+LHezQAM= 
DN: 1.2.840.113549.1.9.1=#0c0e706970706f40706970706f2e6974,CN=camobile.gateway.local,O=CA Technolegies inc.,ST=USA,C=USA
subjectAltNames: [CAMobile.gateway.local, 10.22.238.196, api.camobile.gateway.com, api.camobile.gateway.local] 


Environment

Release:
Component: APIMBL

Resolution

For Android devices running Android 7 or high, you must make sure that Secure AMS has been enabled: https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-1/Android/Android_2-1/Set-Up-Project-and-Start-the-SDK.html

Optionally,  you can ignore the Hostname Verification during development, here is how to ignore Hostname Verification using the SDK: 

MAS.setConnectionListener(new MASConnectionListener() {
    @Override
    public void onObtained(HttpURLConnection connection) {
        ((HttpsURLConnection) connection).setHostnameVerifier(new HostnameVerifier() {
            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });
    }

    @Override
    public void onConnected(HttpURLConnection connection) {

    }
});

Note: This could cause insecure network traffic due to trusting SSL/TLS server certificates for wrong hostnames, it is highly recommended to enable this for development purpose only but not production.