gautamsi / ews-javascript-api

EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
MIT License
281 stars 72 forks source link

nodejs 18: digital envelope routines::unsupported #422

Closed nxps closed 6 months ago

nxps commented 1 year ago

Node.js v18.16.0 ews-javascript-api v0.12.0 @ewsjs/xhr v1.5.0

(async () => {
  const xhr = new XhrApi().useNtlmAuthentication(credentials.userName, credentials.password);
  ews.ConfigurationApi.ConfigureXHR(xhr);

  const service = new ews.ExchangeService(ews.ExchangeVersion.Exchange2016);
  service.Credentials = new ews.WebCredentials(credentials.userName, credentials.password);
  service.Url = new ews.Uri(credentials.url);
  service.AcceptGzipEncoding = false;

  const emailMessage = new ews.EmailMessage(service);
  emailMessage.ToRecipients.Add(mail);
  emailMessage.Subject = 'Email sent with EWS API';

  const messageBody = new ews.MessageBody();
  messageBody.BodyType = ews.BodyType.HTML;
  messageBody.Text = 'Test email sent using EWS API';
  emailMessage.Body = messageBody;
  try {
    await emailMessage.SendAndSaveCopy();
    console.log('success');
  } catch (error) {
    console.log(error);
  }
})()

error log:

SoapFaultDetails {
  message: 'error:0308010C:digital envelope routines::unsupported',
  InnerException: null,
  faultCode: null,
  faultString: null,
  faultActor: null,
  responseCode: 127,
  errorCode: 0,
  exceptionType: null,
  lineNumber: 0,
  positionWithinLine: 0,
  errorDetails: DictionaryWithStringKey {
    keys: [],
    keysToObjs: {},
    objects: {},
    keyPicker: [Function (anonymous)]
  },
  HttpStatusCode: undefined
}
gautamsi commented 1 year ago

see this - https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported

you may be able to use it with legacy ssl provider, I am not sure if i can fix the ntlm-client lib easily, any help is welcome

tomer953 commented 1 year ago

Hi, I'm having trouble as well with ews and ntlm auth. I guess this is related, right? https://github.com/ewsjs/xhr/issues/13 https://github.com/ewsjs/ntlm-client/issues/2

guicara commented 1 year ago

Hello,

I have the same issue after upgrading my project to Node 18 (previously Node 16).

Using NODE_OPTIONS=--openssl-legacy-provider, as explained in the Stack Overflow page linked by @gautamsi, fixed my issue.

bfredo123 commented 8 months ago

Same here, I have to use Node 18+ for other packages, and I could see that creating a 'md4' hash triggers this error (even without ews-javascript-api). So any upgrade to git rid of this 'md4' hash in ews-javascript-api and ewsjs/whr will be more than welcome! Thank you, and thank you again for these great packages which help me a lot!

gautamsi commented 6 months ago

have updated to 0.14 which should fix this issue (ccd9d300fc6f5e27f81f5f42c9d8c901e82da0b5)

NODE_OPTIONS=--openssl-legacy-provider` should have been the workaround as I tested today.