# Certificates

By default, CJGuestCall uses a UIAlertView to prompt users of your app if they wish to continue placing a call when the certificate provided is invalid. This behavior can be overridden by implementing your own invalid certificate handling.

If you are using the high-level CJGuestCallViewController object, then you can not override the default invalid certificate behavior. You can simply skip this section.

## CJGuestInvalidCertDelegate

This delegate allows you to control your app's behavior when encountering an invalid certificate.

To use this delegate to overide the default invalid certificate behavior, first you need to implement onInvalidCert:certSubjectCN:referenceID:invalidReason:subjectCertificateData:intermediateCACertificateData:invalidCertCallback: to accept or reject the certificate. From inside this method, to accept the certificate call accept on the CJGuestInvalidCertCallback argument. To reject the certificate call reject on the CJGuestInvalidCertCallback argument. Second, set the invalidCertDelegate property on CJGuestCall to your implementation.

Here is an implementation that accepts all invalid certificates.

    @interface YourClass () <CJGuestCallBarViewDelegate>

    - (id)init
    {
        self = [super init];
        if (self) {
            CJGuestCall * call = [CJGuestCall sharedInstance];

            ...

            [call setInvalidCertDelegate:self];

            ...
        }
        return self;
    }

    -(void) onInvalidCert:(NSString*)certFingerprint
                    certSubjectCN:(NSString*)certSubjectCN
                      referenceID:(NSString*)referenceID
                    invalidReason:(NSArray*)invalidReason
           subjectCertificateData:(NSString*)subjectCertificateData
    intermediateCACertificateData:(NSArray*)intermediateCACertificateData
              invalidCertCallback:(id)invalidCertCallback
    {
        [invalidCertCallback accept];
    }

To reject all invalid certificates you would call reject instead, [invalidCertCallback reject].