use of org.jruby.ext.openssl.impl.NotVerifiedPKCS7Exception in project jruby-openssl by jruby.
the class PKCS7 method verify.
@JRubyMethod(rest = true)
public IRubyObject verify(IRubyObject[] args) {
final Ruby runtime = getRuntime();
IRubyObject certs;
X509Store store;
IRubyObject indata = runtime.getNil();
IRubyObject vflags = runtime.getNil();
switch(Arity.checkArgumentCount(runtime, args, 2, 4)) {
case 4:
vflags = args[3];
case 3:
indata = args[2];
default:
store = (X509Store) args[1];
certs = args[0];
}
final int flg = vflags.isNil() ? 0 : RubyNumeric.fix2int(vflags);
if (indata.isNil())
indata = getData();
final BIO in = indata.isNil() ? null : obj2bio(indata);
List<X509AuxCertificate> x509s = certs.isNil() ? null : getAuxCerts(certs);
final Store storeStr = store.getStore();
final BIO out = BIO.mem();
boolean result = false;
try {
p7.verify(x509s, storeStr, in, out, flg);
result = true;
} catch (NotVerifiedPKCS7Exception e) {
// result = false;
} catch (PKCS7Exception pkcs7e) {
if (isDebug(runtime)) {
// runtime.getOut().println(pkcs7e);
pkcs7e.printStackTrace(runtime.getOut());
}
// result = false;
}
IRubyObject data = membio2str(getRuntime(), out);
setData(data);
return result ? runtime.getTrue() : runtime.getFalse();
}
Aggregations