Code example for X500Principal

0
                kpg.initialize(new KeyPairGeneratorSpec.Builder(getApplicationContext())
                        .setAlias(alias)
                        .setStartDate(now)
                        .setEndDate(end)
                        .setSerialNumber(BigInteger.valueOf(1))
                        .setSubject(new X500Principal("CN=test1"))
                        .build()); 
 
                KeyPair kp = kpg.generateKeyPair();
// END_INCLUDE(generate) 
                return true; 
            } catch (NoSuchAlgorithmException e) {
                Log.w(TAG, "Could not generate key", e);
                return false; 
            } catch (InvalidAlgorithmParameterException e) {
                Log.w(TAG, "Could not generate key", e);
                return false; 
            } catch (NoSuchProviderException e) {
                Log.w(TAG, "Could not generate key", e);
                return false; 
            }